List of usage examples for com.lowagie.text.pdf PdfPCell setBorderWidthRight
public void setBorderWidthRight(float borderWidthRight)
From source file:org.unitime.timetable.webutil.timegrid.PdfExamGridTable.java
License:Open Source License
public void printHeaderCell(String name, boolean vertical, boolean eod, boolean eol) { PdfPCell c = createCell(); if (!eol && !eod) c.setBorderWidthRight(0); if (name == null) { c.setBorderWidthLeft(0);/*from w w w.ja v a2 s . co m*/ c.setBorderWidthTop(0); c.setBorderWidthBottom(0); } else { addText(c, name); } iPdfTable.addCell(c); }
From source file:org.unitime.timetable.webutil.timegrid.PdfExamGridTable.java
License:Open Source License
public void printCell(ExamGridModel model, int day, int slot, int idx, int maxIdx, boolean head, boolean vertical, boolean in, boolean eod, boolean eol) { ExamPeriod period = getPeriod(day, slot); ExamGridCell cell = model.getAssignment(period, idx); PdfPCell c = createCell(); c.setBorderWidthTop(head || (!in && !vertical) ? 1 : 0); c.setBorderWidthRight(eod || eol ? 1 : 0); if (cell == null) { String bgColor = model.getBackground(period); if (bgColor == null && !model.isAvailable(period)) bgColor = sBgColorNotAvailable; if (period == null) bgColor = sBgColorNotAvailable; if (bgColor != null) c.setBackgroundColor(getColor(bgColor)); c.setBorderWidthBottom(idx < maxIdx ? 0 : 1); addText(c, " "); } else {// w ww . j a va 2 s .c o m String bgColor = cell.getBackground(); if (iForm.getBackground() == sBgNone && !sBgColorNotAvailable.equals(bgColor)) { if (!model.isAvailable(period)) bgColor = sBgColorNotAvailableButAssigned; } if (bgColor != null) c.setBackgroundColor(getColor(bgColor)); addText(c, cell.getName()); if (iForm.getResource() != sResourceRoom) addText(c, cell.getRoomName()); else addText(c, cell.getShortCommentNoColors() == null ? "" : cell.getShortCommentNoColors()); } iPdfTable.addCell(c); }
From source file:org.unitime.timetable.webutil.timegrid.PdfExamGridTable.java
License:Open Source License
public void printRowHeaderCell(String name, int idx, int maxIdx, boolean vertical, boolean head, boolean in) { PdfPCell c = createCell(); c.setBorderWidthTop(idx == 0 && (head || (!in && !vertical)) ? 1 : 0); c.setBorderWidthBottom(idx < maxIdx ? 0 : 1); c.setBorderWidthRight(0); if (idx == 0) addText(c, name);/*from www. j av a2s . co m*/ iPdfTable.addCell(c); }
From source file:org.unitime.timetable.webutil.timegrid.PdfTimetableGridTable.java
License:Open Source License
public void printToPdf(TimetableGridModel model, int rowNumber) throws Exception { model.clearRendered();/*w ww .ja v a 2 s.co m*/ if (iTable.isDispModePerWeek()) { createTable(); printHeader(model, 0); } else { if (rowNumber == 0) { createTable(); printHeader(model, 0); } } if (iTable.isDispModeInRow()) { int maxIdx = model.getMaxIdxForDay(iDay, iTable.firstSlot(), iTable.lastSlot()); for (int idx = 0; idx <= maxIdx; idx++) { PdfPCell c = createCell(); c.setBorderWidthTop(0); if (idx == 0) addText(c, model.getName() + (model.getSize() > 0 ? " (" + model.getSize() + ")" : ""), true); c.setBorderWidthBottom(idx == maxIdx ? 1 : 0); c.setColspan(12); iPdfTable.addCell(c); for (int slot = iTable.firstSlot(); slot <= iTable.lastSlot(); slot++) { int slotsToEnd = iTable.lastSlot() - slot + 1; TimetableGridCell cell = model.getCell(iDay, slot, idx); int length = (cell == null ? 1 : cell.getLength() + cell.getSlot() - slot); int colSpan = (cell == null ? 1 : Math.min(length, slotsToEnd)); if (cell == null) { String bgColor = model.getBackground(iDay, slot); if (bgColor == null && !model.isAvailable(iDay, slot)) bgColor = TimetableGridCell.sBgColorNotAvailable; c = createCell(); c.setBorderWidthTop(0); c.setBorderWidthBottom( idx == maxIdx ? 1 : model.getCell(iDay, slot, idx + 1) != null ? 1 : 0); c.setBorderWidthLeft(0); boolean eod = (slot == iTable.lastSlot()); boolean in = !eod && model.getCell(iDay, slot + 1, idx) == null && ((slot + 1 - iTable.firstSlot()) % iTable.nrSlotsPerPeriod()) != 0; c.setBorderWidthRight(eod || !in ? 1 : 0); c.setColspan(colSpan); if (bgColor != null) c.setBackgroundColor(getColor(bgColor)); iPdfTable.addCell(c); } else { String bgColor = cell.getBackground(); if (iTable.getBgMode() == TimetableGridModel.sBgModeNone) { for (int i = 0; i < length; i++) if (!model.isAvailable(iDay, slot + i)) { bgColor = TimetableGridCell.sBgColorNotAvailableButAssigned; break; } } c = createCell(); c.setBorderWidthTop(0); c.setBorderWidthLeft(0); c.setColspan(colSpan); c.setBackgroundColor(getColor(bgColor)); addText(c, cell.getName()); if (iTable.getShowTimes()) addText(c, cell.getTime()); if (iTable.getResourceType() != TimetableGridModel.sResourceTypeRoom) addText(c, cell.getRoomName()); if (iTable.getResourceType() != TimetableGridModel.sResourceTypeInstructor && iTable.getShowInstructors() && !cell.getInstructor().isEmpty()) addText(c, cell.getInstructor()); if (iTable.getShowComments()) addText(c, cell.getShortCommentNoColors() == null ? null : cell.getShortCommentNoColors()); if (iTable.getWeek() == -100 && cell.hasDays() && !cell.getDays().equals(iTable.getDefaultDatePatternName())) addText(c, cell.getDays()); iPdfTable.addCell(c); slot += length - 1; } } } } else if (iTable.isDispModePerWeekHorizontal()) { for (int day = iTable.startDay(); day <= iTable.endDay(); day++) { int maxIdx = model.getMaxIdxForDay(day, iTable.firstSlot(), iTable.lastSlot()); for (int idx = 0; idx <= maxIdx; idx++) { PdfPCell c = createCell(); c.setBorderWidthTop(0); if (idx == 0) addText(c, Constants.DAY_NAME[day], true); c.setBorderWidthBottom(idx == maxIdx ? 1 : 0); c.setColspan(12); iPdfTable.addCell(c); for (int slot = iTable.firstSlot(); slot <= iTable.lastSlot(); slot++) { int slotsToEnd = iTable.lastSlot() - slot + 1; TimetableGridCell cell = model.getCell(day, slot, idx); int length = (cell == null ? 1 : cell.getLength() + cell.getSlot() - slot); int colSpan = (cell == null ? 1 : Math.min(length, slotsToEnd)); if (cell == null) { String bgColor = model.getBackground(day, slot); if (bgColor == null && !model.isAvailable(day, slot)) bgColor = TimetableGridCell.sBgColorNotAvailable; c = createCell(); c.setBorderWidthTop(0); c.setBorderWidthBottom( idx == maxIdx ? 1 : model.getCell(day, slot, idx + 1) != null ? 1 : 0); c.setBorderWidthLeft(0); boolean eod = (slot == iTable.lastSlot()); boolean in = !eod && model.getCell(day, slot + 1, idx) == null && ((slot + 1 - iTable.firstSlot()) % iTable.nrSlotsPerPeriod()) != 0; c.setBorderWidthRight(eod || !in ? 1 : 0); iPdfTable.addCell(c); } else { String bgColor = cell.getBackground(); if (iTable.getBgMode() == TimetableGridModel.sBgModeNone) { for (int i = 0; i < length; i++) if (!model.isAvailable(day, slot + i)) { bgColor = TimetableGridCell.sBgColorNotAvailableButAssigned; break; } } c = createCell(); c.setBorderWidthTop(0); c.setBorderWidthLeft(0); c.setColspan(colSpan); if (bgColor != null) c.setBackgroundColor(getColor(bgColor)); addText(c, cell.getName()); if (iTable.getShowTimes()) addText(c, cell.getTime()); if (iTable.getResourceType() != TimetableGridModel.sResourceTypeRoom) addText(c, cell.getRoomName()); if (iTable.getResourceType() != TimetableGridModel.sResourceTypeInstructor && iTable.getShowInstructors() && !cell.getInstructor().isEmpty()) addText(c, cell.getInstructor()); if (iTable.getShowComments()) addText(c, cell.getShortCommentNoColors() == null ? null : cell.getShortCommentNoColors()); if (iTable.getWeek() == -100 && cell.hasDays() && !cell.getDays().equals(iTable.getDefaultDatePatternName())) addText(c, cell.getDays()); iPdfTable.addCell(c); slot += length - 1; } } } } } else if (iTable.isDispModeWeekByWeekHorizontal()) { Calendar cal = Calendar.getInstance(Locale.US); cal.setTime(iTable.iFirstDate); for (int d = 0; d < 365; d++) { if (d > 0) cal.add(Calendar.DAY_OF_YEAR, 1); int date = d + iTable.iFirstDay; if (model.getFirstDay() >= 0 && (date < model.getFirstDay() || date > model.getFirstDay() + 6)) continue; int day = d % 7; if (day < iTable.startDay() || day > iTable.endDay()) continue; boolean hasClasses = false; for (int slot = iTable.firstSlot(); slot <= iTable.lastSlot(); slot++) { if (model.getCell(day, slot, 0, date) != null) { hasClasses = true; break; } } if (!hasClasses) continue; int maxIdx = model.getMaxIdxForDay(day, iTable.firstSlot(), iTable.lastSlot(), date); for (int idx = 0; idx <= maxIdx; idx++) { PdfPCell c = createCell(); c.setBorderWidthTop(0); if (idx == 0) addText(c, Constants.DAY_NAME[day] + " " + sDF.format(cal.getTime()), true); c.setBorderWidthBottom(idx == maxIdx ? 1 : 0); c.setColspan(12); iPdfTable.addCell(c); for (int slot = iTable.firstSlot(); slot <= iTable.lastSlot(); slot++) { int slotsToEnd = iTable.lastSlot() - slot + 1; TimetableGridCell cell = model.getCell(day, slot, idx, date); int length = (cell == null ? 1 : cell.getLength() + cell.getSlot() - slot); int colSpan = (cell == null ? 1 : Math.min(length, slotsToEnd)); if (cell == null) { String bgColor = model.getBackground(day, slot); if (bgColor == null && !model.isAvailable(day, slot)) bgColor = TimetableGridCell.sBgColorNotAvailable; c = createCell(); c.setBorderWidthTop(0); c.setBorderWidthBottom( idx == maxIdx ? 1 : model.getCell(day, slot, idx + 1, date) != null ? 1 : 0); c.setBorderWidthLeft(0); boolean eod = (slot == iTable.lastSlot()); boolean in = !eod && model.getCell(day, slot + 1, idx, date) == null && ((slot + 1 - iTable.firstSlot()) % iTable.nrSlotsPerPeriod()) != 0; c.setBorderWidthRight(eod || !in ? 1 : 0); iPdfTable.addCell(c); } else { String bgColor = cell.getBackground(); if (iTable.getBgMode() == TimetableGridModel.sBgModeNone) { for (int i = 0; i < length; i++) if (!model.isAvailable(day, slot + i)) { bgColor = TimetableGridCell.sBgColorNotAvailableButAssigned; break; } } c = createCell(); c.setBorderWidthTop(0); c.setBorderWidthLeft(0); c.setColspan(colSpan); if (bgColor != null) c.setBackgroundColor(getColor(bgColor)); addText(c, cell.getName()); if (iTable.getShowTimes()) addText(c, cell.getTime()); if (iTable.getResourceType() != TimetableGridModel.sResourceTypeRoom) addText(c, cell.getRoomName()); if (iTable.getResourceType() != TimetableGridModel.sResourceTypeInstructor && iTable.getShowInstructors() && !cell.getInstructor().isEmpty()) addText(c, cell.getInstructor()); if (iTable.getShowComments()) addText(c, cell.getShortCommentNoColors() == null ? null : cell.getShortCommentNoColors()); iPdfTable.addCell(c); slot += length - 1; } } } } } else { //isDispModePerWeekVertical for (int day = iTable.startDay(); day <= iTable.endDay(); day++) { int maxIdx = model.getMaxIdxForDay(day, iTable.firstSlot(), iTable.lastSlot()); for (int idx = 0; idx <= maxIdx; idx++) { PdfPCell c = null; for (int slot = iTable.lastSlot(); slot >= iTable.firstSlot(); slot--) { int slotsToEnd = slot + 1 - iTable.firstSlot(); TimetableGridCell cell = model.getCell(day, slot, idx); int length = (cell == null ? 1 : 1 + slot - cell.getSlot()); int colSpan = (cell == null ? 1 : Math.min(length, slotsToEnd)); if (cell == null) { String bgColor = model.getBackground(day, slot); if (bgColor == null && !model.isAvailable(day, slot)) bgColor = TimetableGridCell.sBgColorNotAvailable; c = createCell(); c.setBorderWidthTop(0); c.setMinimumHeight(100f); c.setBorderWidthBottom( idx == maxIdx ? 1 : model.getCell(day, slot, idx + 1) != null ? 1 : 0); c.setBorderWidthLeft(slot == iTable.lastSlot() ? 1 : 0); boolean eod = (slot == iTable.firstSlot()); boolean in = !eod && model.getCell(day, slot - 1, idx) == null && ((slot - iTable.firstSlot()) % iTable.nrSlotsPerPeriod()) != 0; c.setBorderWidthRight(eod || !in ? 1 : 0); iPdfTable.addCell(c); } else { String bgColor = cell.getBackground(); if (iTable.getBgMode() == TimetableGridModel.sBgModeNone) { for (int i = 0; i < length; i++) if (!model.isAvailable(day, slot - i)) { bgColor = TimetableGridCell.sBgColorNotAvailableButAssigned; break; } } c = createCell(); c.setBorderWidthTop(0); c.setBorderWidthLeft(slot == iTable.lastSlot() ? 1 : 0); c.setColspan(colSpan); if (bgColor != null) c.setBackgroundColor(getColor(bgColor)); if (iTable.getWeek() == -100 && cell.hasDays() && !cell.getDays().equals(iTable.getDefaultDatePatternName())) addTextVertical(c, cell.getDays()); if (iTable.getShowTimes()) addText(c, cell.getTime()); if (iTable.getResourceType() != TimetableGridModel.sResourceTypeRoom) addTextVertical(c, cell.getRoomName()); if (iTable.getResourceType() != TimetableGridModel.sResourceTypeInstructor && iTable.getShowInstructors() && !cell.getInstructor().isEmpty()) addTextVertical(c, cell.getInstructor()); if (iTable.getShowComments()) addTextVertical(c, cell.getShortCommentNoColors() == null ? null : cell.getShortCommentNoColors()); addTextVertical(c, cell.getName()); iPdfTable.addCell(c); slot -= length - 1; } } c = createCell(); c.setBorderWidthTop(0); c.setBorderWidthLeft(0); if (idx == 0) addTextVertical(c, Constants.DAY_NAME[day], true); c.setBorderWidthBottom(idx == maxIdx ? 1 : 0); c.setColspan(12); iPdfTable.addCell(c); } } /* int step = iTable.nrSlotsPerPeriod(); for (int slot=iTable.firstSlot();slot<=iTable.lastSlot();slot+=step) { int time = slot * Constants.SLOT_LENGTH_MIN + Constants.FIRST_SLOT_TIME_MIN; int slotsToEnd = iTable.lastSlot()-slot+1; if ((slot%iTable.nrSlotsPerPeriod()) == 0) { c = createCell("TimetableHeadCell"+(slot==iTable.firstSlot()?"":"In")+"Vertical"); addText(c, Constants.toTime(time), true); iPdfTable.addCell(c); } else { c = createCell("TimetableHeadCellInVertical"); iPdfTable.addCell(c); } for (int day=iTable.startDay();day<=iTable.endDay();day++) { int maxIdx = model.getMaxIdxForDay(day,iTable.firstSlot(),iTable.lastSlot()); for (int idx=0;idx<=maxIdx;idx++) { TimetableGridCell cell = model.getCell(day,slot, idx); if (model.isRendered(day,slot,idx)) continue; int rowSpan = (cell==null?1:Math.min(cell.getLength()+cell.getSlot()-slot,slotsToEnd)); int colSpan = (iTable.getResourceType()==TimetableGridModel.sResourceTypeDepartment && cell!=null?1:model.getDepth(day,slot,idx,maxIdx,rowSpan)); model.setRendered(day,slot,idx,colSpan,rowSpan); int rowSpanDivStep = (int)Math.ceil(((double)rowSpan)/step); if (cell==null) { String bgColor = model.getBackground(day,slot); if (bgColor==null && !model.isAvailable(day,slot)) bgColor=TimetableGridCell.sBgColorNotAvailable; boolean eol = (day==iTable.endDay() && (idx+colSpan-1)==maxIdx); c = createCell("TimetableCell"+(slot==iTable.firstSlot()?"":"In")+"Vertical"+(eol?"EOL":"")); c.setColspan(colSpan); //c.setRowspan(rowSpanDivStep); if (bgColor!=null) c.setBackgroundColor(getColor(bgColor)); iPdfTable.addCell(c); } else { String bgColor = cell.getBackground(); if (iTable.getBgMode()==TimetableGridModel.sBgModeNone) { for (int i=0;i<cell.getLength();i++) if (!model.isAvailable(day,slot+i)) { bgColor = TimetableGridCell.sBgColorNotAvailableButAssigned; break; } } boolean eol = (day==iTable.endDay()); c = createCell("TimetableCell"+(slot==iTable.firstSlot()?"":"In")+"Vertical" + (eol?"EOL":"")); c.setColspan(colSpan); //c.setRowspan(rowSpanDivStep); if (bgColor!=null) c.setBackgroundColor(getColor(bgColor)); addText(c, cell.getName()); if (iTable.getResourceType()!=TimetableGridModel.sResourceTypeRoom) addText(c, cell.getRoomName()); if (iTable.getShowComments()) addText(c, cell.getShortComment()==null?"":cell.getShortComment()); if (iTable.getWeek()==-100 && cell.hasDays() && !cell.getDays().equals(iTable.getDefaultDatePatternName())) addText(c, cell.getDays()); iPdfTable.addCell(c); } } } } */ } if (iTable.isDispModePerWeek()) { flushTable(); } }