int posY = convert(10);
int posX = convert(10);
JRPrintImage imageBkg = printImage("titleReport.gif", posX, posY, 535, 45);
JRPrintImage logoImage = printImage("corporateLogo.jpg", posX+11, posY, 65, 45);
JRPrintText titleText = insertTitle("Quadro de Hor�rios", posX+200, posY+11, 330);
for (String date : listDate) {
posX = convert(10);
GDDate actualDate = new GDDate(date);
RegistrationMap registrationMap = system.getRegistratioMap();
page.addElement(imageBkg);
page.addElement(logoImage);
page.addElement(titleText);
posY += 50;
JRPrintText text = new JRBasePrintText(jasperPrint.getDefaultStyleProvider());
text.setText("Data: "+date);
text.setX(posX);
text.setY(posY);
text.setWidth(150);
text.setHeight(12);
text.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_LEFT);
text.setLineSpacingFactor(2.0f);
text.setLeadingOffset(-4.0f);
text.setStyle(normalStyle);
page.addElement(text);
text = new JRBasePrintText(jasperPrint.getDefaultStyleProvider());
text.setText("Dia da Semana: "+new SimpleDateFormat("EEEEE").format(new GDDate(date).getDate()));
text.setX(posX+300);
text.setY(posY);
text.setWidth(220);
text.setHeight(12);
text.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_LEFT);
text.setLineSpacingFactor(2.0f);
text.setLeadingOffset(-4.0f);
text.setStyle(normalStyle);
page.addElement(text);
posY += 17;
text = new JRBasePrintText(jasperPrint.getDefaultStyleProvider());
text.setText("Funcionamento: das " + startWorkTime + ":00 �s " + endWorkTime + ":00");
text.setX(posX);
text.setY(posY);
text.setWidth(290);
text.setHeight(12);
text.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_LEFT);
text.setLineSpacingFactor(2.0f);
text.setLeadingOffset(-4.0f);
text.setStyle(normalStyle);
page.addElement(text);
text = new JRBasePrintText(jasperPrint.getDefaultStyleProvider());
text.setText("Impresso em: "+new GDDate().getFormatedDate());
text.setX(posX+300);
text.setY(posY);
text.setWidth(220);
text.setHeight(12);
text.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_LEFT);
text.setLineSpacingFactor(2.0f);
text.setLeadingOffset(-4.0f);
text.setStyle(normalStyle);
page.addElement(text);
posY += 16;
text = new JRBasePrintText(jasperPrint.getDefaultStyleProvider());
text.setText("Obs. Marque com \"X\" os alunos faltantes.\n* Aluno de Reposi��o");
text.setX(posX);
text.setY(posY);
text.setWidth(530);
text.setHeight(26);
text.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_LEFT);
text.setLineSpacingFactor(2.0f);
text.setLeadingOffset(-4.0f);
text.setStyle(normalStyle);
page.addElement(text);
posY += 23;
for(int periods=0; periods<3; periods++){
String weekDay = new SimpleDateFormat("EEEEE").format(new GDDate(date).getDate()).replace("-feira", "");
if(getHourVacancy(weekDay, ((periods+1)*6)+1, ((2+periods)*6))>0){
posX = convert(10);
JRPrintRectangle rectangle = new JRBasePrintRectangle(jasperPrint.getDefaultStyleProvider());
rectangle.setX(posX);
rectangle.setY(posY);
rectangle.setWidth(535);
rectangle.setHeight(14);
rectangle.setBackcolor(new Color(153, 153, 153));
page.addElement(rectangle);
text = new JRBasePrintText(jasperPrint.getDefaultStyleProvider());
text.setText(period.get(periods));
text.setX(posX);
text.setY(posY);
text.setWidth(535);
text.setHeight(14);
text.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_CENTER);
text.setLineSpacingFactor(2.0f);
text.setLeadingOffset(-4.0f);
text.setStyle(boldStyle);
page.addElement(text);
posY += 14;
int posYTemp = 0;
for(int hour=(((periods+1)*6)+1); hour<=((2+periods)*6); hour++){
if(getMaxVacancy(weekDay, hour)>0){
// if(!isHourVacancy(j)){
int numberOfColumns = getHourVacancy(weekDay, ((periods+1)*6)+1, ((2+periods)*6));
int width = Math.round(535/numberOfColumns);
rectangle = new JRBasePrintRectangle(jasperPrint.getDefaultStyleProvider());
rectangle.setX(posX);
rectangle.setY(posY);
rectangle.setWidth(width);
rectangle.setHeight(14);
rectangle.setBackcolor(new Color(204, 204, 204));
page.addElement(rectangle);
text = new JRBasePrintText(jasperPrint.getDefaultStyleProvider());
text.setText(String.valueOf(hour));
text.setX(posX);
text.setY(posY);
text.setWidth(width);
text.setHeight(14);
text.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_CENTER);
text.setLineSpacingFactor(2.0f);
text.setLeadingOffset(-4.0f);
text.setStyle(boldStyle);
page.addElement(text);
posYTemp =posY;
for (int box = 0; box < numberTotalComputers; box++) {
posYTemp +=14;
rectangle = new JRBasePrintRectangle(jasperPrint.getDefaultStyleProvider());
rectangle.setX(posX);
rectangle.setY(posYTemp);
rectangle.setWidth(width);
rectangle.setHeight(14);
page.addElement(rectangle);
JRPrintLine line = new JRBasePrintLine(jasperPrint.getDefaultStyleProvider());
line.setX(posX+14);
line.setY(posYTemp);
line.setWidth(0);
line.setHeight(14);
page.addElement(line);
}
actualDate.setHourOfDay(hour);
MergeSortAlgorithm sortAlgorithm = new MergeSortAlgorithm();
List<RegistrationAppointment> registrationList = registrationMap.getAppointmentsOnThatWeekDay(actualDate);
if(registrationList.size() > 1)
sortAlgorithm.sortRegistrationAppointmentByName(registrationList);
posYTemp =posY+2;
for (int studentIndex = 0; studentIndex < registrationList.size(); studentIndex++) {
posYTemp +=14;
text = new JRBasePrintText(jasperPrint.getDefaultStyleProvider());
text.setText(registrationList.get(studentIndex).getRegistration().getStudent().getName());
text.setX(posX+16);
text.setY(posYTemp);
text.setWidth(width-16);
text.setHeight(12);
text.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_LEFT);
text.setLineSpacingFactor(2.0f);
text.setLeadingOffset(-4.0f);
text.setStyle(studentNameStyle);
page.addElement(text);
}
List<RegistrationAppointment> replacementList = registrationMap.getReplacementsOnThatDay(actualDate);
if(replacementList.size() > 1)
sortAlgorithm.sortRegistrationAppointmentByName(replacementList);
for (int studentIndex = 0; studentIndex < replacementList.size(); studentIndex++) {
posYTemp +=14;
text = new JRBasePrintText(jasperPrint.getDefaultStyleProvider());
text.setText("* "+replacementList.get(studentIndex).getRegistration().getStudent().getName());
text.setX(posX+16);
text.setY(posYTemp);
text.setWidth(width-16);
text.setHeight(12);
text.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_LEFT);
text.setLineSpacingFactor(2.0f);
text.setLeadingOffset(-4.0f);
text.setStyle(studentNameStyle);
page.addElement(text);
}
posX += width;
}