Example showing
pie-chart drawn using GINOGRAF
!
module
use System%Windows%Forms
use System
use GinoGraphics
implicit none
type,extends(System%Windows%Forms%Form), namespace(pie) :: Form1
class(System%Windows%Forms%PictureBox),private ,pointer :: pictureBox1
type(System%ComponentModel%Container),pointer, private :: components
contains
initial,pass,public :: Form1_ctor
procedure,pass,private :: Dispose
procedure,pass,private :: InitializeComponent
procedure,pass,private :: pictureBox1_Paint
end type Form1
contains
subroutine Form1_ctor(this)
class(Form1) :: this
call this%InitializeComponent()
!
! Add any other Initialization statements here
!
end subroutine
!
! Clean up any resources being used
!
subroutine Dispose(this,disposing)
class(Form1) :: this
logical(1) :: disposing
if( disposing .eqv. .true._1 ) then
if( associated( this%components ) ) then
call this%components%Dispose()
end if
call this%System%Windows%Forms%Form%Dispose( disposing )
end if
end subroutine
! <--InitializeComponent-->
! Required method for Designer support - DO NOT modify
! the contents of this method with the code editor.
!
subroutine InitializeComponent(this)
class(Form1) :: this
type(System%Drawing%Point),pointer :: ASPTMP0
type(System%Drawing%Size),pointer :: ASPTMP1
type(System%Windows%Forms%PaintEventHandler),pointer :: ASPTMP2
type(System%Drawing%Size),pointer :: ASPTMP3
type(System%Drawing%Size),pointer :: ASPTMP4
class(System%Windows%Forms%Control%ControlCollection),pointer :: ASPTMP5
allocate(this%pictureBox1,source=System%Windows%Forms%PictureBox())
call this%SuspendLayout()
!
!pictureBox1
!
allocate(ASPTMP0,source=System%Drawing%Point(16, &
16))
this%pictureBox1%Location => ASPTMP0
this%pictureBox1%Name => USTRING("pictureBox1")
allocate(ASPTMP1,source=System%Drawing%Size(792, &
680))
this%pictureBox1%Size => ASPTMP1
this%pictureBox1%TabIndex = 0
this%pictureBox1%TabStop = .false._1
allocate(ASPTMP2,source=System%Windows%Forms%PaintEventHandler(this%pictureBox1_Paint))
call this%pictureBox1%add_Paint(ASPTMP2)
!
!Form1
!
allocate(ASPTMP3,source=System%Drawing%Size(5, &
13))
this%AutoScaleBaseSize => ASPTMP3
allocate(ASPTMP4,source=System%Drawing%Size(824, &
709))
this%ClientSize => ASPTMP4
ASPTMP5 => this%Controls
call ASPTMP5%Add(this%pictureBox1)
this%Name => USTRING("Form1")
this%Text => USTRING("Form1")
call this%ResumeLayout(.false._1)
end subroutine
subroutine pictureBox1_Paint(this, sender, e)
class(Form1) :: this
class(System%Object),target :: sender
class(System%Windows%Forms%PaintEventArgs),target :: e
type(System%IntPtr) :: hdc
type(System%Drawing%Graphics), pointer :: graphobj
Integer :: NUL = 0
!
! Declare variables
!
! Assign hatch & line style data for area fill
!
integer,dimension(5) :: fill = (/0,0,0,0,0/)
integer,dimension(5) :: line = (/2,7,8,3,5/)
character (len=10) :: str = '*.*.*.*.*.'
!
! Assign segment value data
!
real,dimension(5) :: value1 = (/44.9,21.6,18.7,12.8,2.0/)
real,dimension(5) :: value2 = (/24.9,27.7,21.5,22.7,3.2/)
!
!
character (len=80) :: keys = 'oil*. coal*. natural gas*. nuclear energy*.electricity*. '
!
! Declare Local variables
!
real :: rad,rad1,rad2,xcen,xlen,ycen,ylen,cw,ch
type (GDIM) paper
type (GLIMIT) :: pframe = GLIMIT(30.0,950.0,50.0,720.0)
type (GLIMIT) :: frame1 = GLIMIT(10.0,990.0,50.0,740.0)
type (GLIMIT) :: frame2 = GLIMIT(15.0,985.0,55.0,735.0)
graphobj => e%Graphics
hdc = graphobj%GetHdc()
!
! Enter GINO & initialise device
!
call Gino%OpenGino
call Gino%Mwinao(NUL,hdc.ToInt32())
! call Gino%EnqDrawingLimits(paper,ip)
! factor=min(paper%xpap/1000.0,paper%ypap/750.0)
call Gino%DefinePictureUnits(0.2)
call Gino%SetWorkspaceLimit(1,2001)
call Gino%DefineRGB(0,0.,0.,0.)
call Gino%NewDrawing
call Graf%RestoreAxesSettings
call Gino%SetHardChars
call Graf%SetGraphCharMode(GraphCharMode%GGINOMODE)
cw = 7.5
ch = 7.5
call Gino%SetCharSize(cw,ch)
!
! Set up dimensions and mask
!
xlen=1000.0
ylen=750.0
xcen = xlen/2.5
ycen = ylen/2.0
rad1 = min(xlen/3.0,ylen/3.0)-10.0
rad2 = min(xlen/4.0,ylen/4.0)-10.0
call setmsk(rad2, xcen, ycen)
!
! Output 1st pie chart
!
call Gino%SetLineColour(Colour%GWHITE)
call Graf%SetPieChartStartAngle(120.0)
call Graf%SetPieChartFrame(rad1, xcen, ycen)
call Graf%SetPieChartAnnotation(PieChartAnnotation%GEXTERNAL,0,1,0,0.0)
call Graf%PlotPieChart(5,value1,USTRING(str),2,fill,line)
call Gino%SetMaskMode(Switch%GOFF)
!
! Output 2nd pie chart
!
call Gino%SetLineColour(Colour%GBLACK)
call Graf%SetPieChartFrame(rad2, xcen, ycen)
call Graf%SetPieChartAnnotation(PieChartAnnotation%GINTERNAL,0,1,0,0.0)
call Graf%SetPieChartBoxType(ior(PieChartBoxType%GBOXED,PieChartBoxType%GFILLED),0,10)
call Graf%PlotPieChart(5,value2,USTRING(str),2,fill,line)
!
! Draw key
!
call Gino%SetLineColour(Colour%GWHITE)
call Graf%SetTextChartAttribs(30.0,250.0,Justification%GLEFT,HeaderSwitch%GNOHEAD,-1)
call Graf%DisplayFillColumn(800.0,500.0,5,fill,line,USTRING('*.'))
call Graf%DisplayStringColumn(840.0,500.0,5,USTRING(keys),16,USTRING('*.'))
!
! Write title
!
call Graf%SetPlotFrame(pframe)
call Gino%SetCharSize(2.0*cw,2.0*ch)
call Graf%DrawGraphTitle &
(USTRING('*f101Production and Consumption of Primary Energy'),Justification%GCENTRE,Alignment%GTOP)
!
! Credit
!
call Gino%SetCharSize(0.75*cw,0.75*ch)
call Gino%MoveTo2D(600.0,65.0)
call Gino%DisplayStr(USTRING('Source : EEC'))
call Gino%FlushGraphics
call graphobj%ReleaseHdc(hdc)
end subroutine
!
end module
program main
!.nca (main,add=System%STAThreadAttribute())
type(pie%Form1),pointer :: form
allocate( form )
call System%Windows%Forms%Application%Run(form)
end program