@@ -37,6 +37,7 @@ public class PDFWriter {
37
37
private double weekEventHeaderHeight = 10 ;
38
38
private double agendaColOneWidth = 200 ;
39
39
private double multidayLineHeight = 14 ;
40
+ private double weekAgendaEventHeight = 20 ;
40
41
41
42
private String linePattern = "0" ;
42
43
@@ -47,6 +48,8 @@ public class PDFWriter {
47
48
48
49
private double monthDayWidth ;
49
50
private double monthDayHeight ;
51
+ private double contHeight ;
52
+ private double contWidth ;
50
53
51
54
private double weekDayWidth ;
52
55
private double weekDayHeight ;
@@ -104,7 +107,11 @@ public void generate(String xml, HttpServletResponse resp)
104
107
if (view .compareTo ("matrix" ) == 0 ) {
105
108
this .printMatrix ();
106
109
} else {
107
- this .printWeek ();
110
+ if (view .compareTo ("week_agenda" ) == 0 ) {
111
+ this .printWeekAgenda ();
112
+ } else {
113
+ this .printWeek ();
114
+ }
108
115
}
109
116
}
110
117
}
@@ -185,6 +192,22 @@ private void printWeek() throws Exception {
185
192
this .weekBwBordersDraw ();
186
193
}
187
194
195
+ private void printWeekAgenda () throws Exception {
196
+ this .createPDF (Letter .PORTRAIT );
197
+ this .printHeader ();
198
+ this .printFooter ();
199
+ SchedulerEvent [] events = this .parser .getEvents ();
200
+ while (events .length > 0 ) {
201
+ this .weekAgendaContainerDraw ();
202
+ events = this .weekAgendaEventsDraw (events );
203
+ if (events .length > 0 ) {
204
+ this .page = new Page (this .pdf , Letter .PORTRAIT );
205
+ this .pages .add (this .page );
206
+ this .todayLabelDraw (this .page );
207
+ }
208
+ }
209
+ }
210
+
188
211
private void printWatermark () throws Exception {
189
212
if (watermark == null ) return ;
190
213
@@ -1529,7 +1552,137 @@ private void agendaPagesDraw() throws Exception {
1529
1552
}
1530
1553
}
1531
1554
1555
+
1556
+ private void weekAgendaContainerDraw () throws Exception {
1557
+ String [] cols = this .parser .agendaColsParsing ();
1558
+ double x = this .offsetLeft ;
1559
+ double contWidth = (this .pageWidth )/2 ;
1560
+ double contHeight = (this .pageHeight )/3 ;
1561
+ this .contWidth = contWidth ;
1562
+ this .contHeight = contHeight ;
1563
+
1564
+
1565
+ for (int i = 0 ; i < 3 ; i ++) {
1566
+ double y = this .offsetTop + contHeight *i ;
1567
+ this .weekAgendarDayDraw (cols [i ], contWidth , contHeight , x , y );
1568
+ }
1569
+ x += contWidth ;
1570
+ for (int i = 0 ; i < 2 ; i ++) {
1571
+ double y = this .offsetTop + contHeight *i ;
1572
+ this .weekAgendarDayDraw (cols [i + 3 ], contWidth , contHeight , x , y );
1573
+ }
1574
+
1575
+ double tallContHeight = contHeight /2 ;
1576
+ for (int i = 0 ; i < 2 ; i ++) {
1577
+ double y = this .offsetTop + contHeight *2 + tallContHeight *i ;
1578
+ this .weekAgendarDayDraw (cols [i + 5 ], contWidth , tallContHeight , x , y );
1579
+ }
1580
+ double [] headerLineColor = RGBColor .getColor (this .headerLineColor );
1581
+ for (int i = 0 ; i < 3 ; i ++) {
1582
+ double y = this .offsetTop + contHeight *i ;
1583
+ this .Line (headerLineColor , x , y , x , y + this .monthDayHeaderHeight );
1584
+ }
1585
+ }
1586
+
1587
+ private void weekAgendarDayDraw (String name , double width , double height , double x , double y ) throws Exception {
1588
+ double [] bgColor = RGBColor .getColor (this .bgColor );
1589
+ double [] borderColor = RGBColor .getColor (this .lineColor );
1590
+ double [] textColor = RGBColor .getColor (this .textColor );
1591
+ Box day_cont = new Box ();
1592
+ day_cont .setSize (width , height );
1593
+ day_cont .setPosition (x , y );
1594
+ day_cont .setFillShape (false );
1595
+ day_cont .setPattern (this .linePattern );
1596
+ day_cont .setColor (bgColor );
1597
+ day_cont .drawOn (this .page );
1598
+
1599
+ this .Line (borderColor , 0 , 0 , width , 0 , day_cont );
1600
+ this .Line (borderColor , 0 , 0 , 0 , height , day_cont );
1601
+ this .Line (borderColor , width , 0 , width , height , day_cont );
1602
+ this .Line (borderColor , 0 , height , width , height , day_cont );
1603
+
1604
+ Box label_cont = new Box ();
1605
+ label_cont .setSize (width , this .monthDayHeaderHeight );
1606
+ label_cont .setPosition (0 , 0 );
1607
+ label_cont .setFillShape (true );
1608
+ label_cont .setPattern (this .linePattern );
1609
+ label_cont .setColor (bgColor );
1610
+ label_cont .placeIn (day_cont , 0 , 0 );
1611
+ label_cont .drawOn (this .page );
1612
+
1613
+ TextLine txt = new TextLine (this .f1 , name );
1614
+ x = this .cellOffset + (width - cellOffset - this .f1 .stringWidth (name ))/2 ;
1615
+ y = (this .monthDayHeaderHeight + this .f1 .getSize ()) / 2 ;
1616
+ txt .setPosition (x , y );
1617
+ txt .placeIn (label_cont );
1618
+ txt .setColor (textColor );
1619
+ txt .drawOn (this .page );
1620
+ }
1621
+
1622
+ private SchedulerEvent [] weekAgendaEventsDraw (SchedulerEvent [] events ) throws Exception {
1623
+ double [] borderColor = RGBColor .getColor (this .lineColor );
1624
+ double [] textColor = RGBColor .getColor (this .textColor );
1625
+ int [] offsets = new int [7 ];
1626
+ for (int i = 0 ; i < offsets .length ; i ++)
1627
+ offsets [i ] = 0 ;
1628
+ ArrayList <SchedulerEvent > rest = new ArrayList <SchedulerEvent >();
1629
+
1630
+ for (int i = 0 ; i < events .length ; i ++) {
1631
+ SchedulerEvent event = events [i ];
1632
+ int day = event .getDay ();
1633
+ double cont_height = (day < 5 ) ? this .contHeight : this .contHeight /2 ;
1634
+ double cont_width = this .contWidth ;
1635
+ double x ;
1636
+ switch (day ) {
1637
+ case 0 :
1638
+ case 2 :
1639
+ case 4 :
1640
+ x = this .offsetLeft ;
1641
+ break ;
1642
+ default :
1643
+ x = this .offsetLeft + cont_width ;
1644
+ break ;
1645
+ }
1646
+ double cont_start_y = this .offsetTop + Math .floor (day /2 )*this .contHeight - (day > 5 ? cont_height : 0 );
1647
+ double offset = offsets [day ]*this .weekAgendaEventHeight ;
1648
+ double y = cont_start_y + this .monthDayHeaderHeight + offset ;
1649
+
1650
+ if (cont_start_y + cont_height < y + this .weekAgendaEventHeight ) {
1651
+ rest .add (event );
1652
+ continue ;
1653
+ }
1654
+
1655
+ Box ev = new Box ();
1656
+ ev .setSize (contWidth , this .weekAgendaEventHeight );
1657
+ ev .setPosition (x , y );
1658
+ ev .setFillShape (false );
1659
+ ev .setPattern (this .linePattern );
1660
+ ev .setColor (borderColor );
1661
+ ev .drawOn (this .page );
1662
+
1663
+ this .f1 .setSize (9 );
1664
+ String text = event .getText ();
1665
+ TextLine txt = new TextLine (this .f1 , text );
1666
+ x = this .cellOffset ;
1667
+ y = (this .weekAgendaEventHeight + this .f1 .getSize ()) / 2 ;
1668
+ txt .setPosition (x , y );
1669
+ txt .placeIn (ev );
1670
+ txt .setColor (textColor );
1671
+ txt .drawOn (this .page );
1672
+ offsets [day ]++;
1673
+ }
1674
+ SchedulerEvent [] events_list = new SchedulerEvent [rest .size ()];
1675
+ for (int i = 0 ; i < rest .size (); i ++)
1676
+ events_list [i ] = rest .get (i );
1677
+ return events_list ;
1678
+ }
1679
+
1532
1680
private void todayLabelDraw () throws Exception {
1681
+ Page p1 = this .pages .get (0 );
1682
+ this .todayLabelDraw (p1 );
1683
+ }
1684
+
1685
+ private void todayLabelDraw (Page p1 ) throws Exception {
1533
1686
this .f1 .setSize (10 );
1534
1687
double [] textColor = RGBColor .getColor (this .textColor );
1535
1688
String today = this .parser .getTodatLabel ();
@@ -1538,10 +1691,9 @@ private void todayLabelDraw() throws Exception {
1538
1691
double today_y = this .offsetTop - this .cellOffset ;
1539
1692
todayText .setPosition (today_x , today_y );
1540
1693
todayText .setColor (textColor );
1541
- Page p1 = this .pages .get (0 );
1542
1694
todayText .drawOn (p1 );
1543
1695
}
1544
-
1696
+
1545
1697
private int getEventIndex (SchedulerEvent [] events , int day , int week ,
1546
1698
int month ) throws IOException {
1547
1699
for (int i = 0 ; i < events .length ; i ++) {
0 commit comments