public static JRDesignLine createLine(int x, int y) { JRDesignLine line = new JRDesignLine(); line.setX(0); line.setY(19); line.setWidth(515); line.setHeight(0); return line; }
public static JasperDesign getJasperDesign() throws JRException { // JasperDesign JasperDesign jasperDesign = new JasperDesign(); jasperDesign.setName("ReqIF_Report"); jasperDesign.setPageWidth(595); jasperDesign.setPageHeight(842); jasperDesign.setColumnWidth(515); jasperDesign.setColumnSpacing(0); jasperDesign.setLeftMargin(40); jasperDesign.setRightMargin(40); jasperDesign.setTopMargin(50); jasperDesign.setBottomMargin(50); // Fonts JRDesignStyle normalStyle = createNormalStyle(9); jasperDesign.addStyle(normalStyle); JRDesignStyle boldStyle = createBoldStyle(9); jasperDesign.addStyle(boldStyle); JRDesignStyle italicStyle = createItalicStyle(9); jasperDesign.addStyle(italicStyle); // Parameters JRDesignParameter parameter = new JRDesignParameter(); parameter.setName("ReportTitle"); parameter.setValueClass(java.lang.String.class); jasperDesign.addParameter(parameter); // Query JRDesignQuery query = new JRDesignQuery(); query.setText(""); jasperDesign.setQuery(query); // Fields JRDesignField field = createField("Id"); jasperDesign.addField(field); field = createField("FirstName"); jasperDesign.addField(field); field = createField("LastName"); jasperDesign.addField(field); field = createField("City"); jasperDesign.addField(field); field = createField("Street"); jasperDesign.addField(field); // Bands JRDesignBand band = new JRDesignBand(); band.setHeight(20); JRDesignTextField textField = createTextField(0, 4); band.addElement(textField); JRDesignLine line = createLine(0, 19); band.addElement(line); band = new JRDesignBand(); band.setHeight(20); line = createLine(0, -1); band.addElement(line); JRDesignStaticText staticText = new JRDesignStaticText(); // band.addElement(staticText); // band.addElement(textField); // Page header band = new JRDesignBand(); band.setHeight(20); JRDesignFrame frame = new JRDesignFrame(); frame.setX(0); frame.setY(5); frame.setWidth(515); frame.setHeight(15); frame.setForecolor(new Color(0x33, 0x33, 0x33)); frame.setBackcolor(new Color(0x33, 0x33, 0x33)); frame.setMode(ModeEnum.OPAQUE); band.addElement(frame); staticText = createStaticText("ID", 0, 0); staticText.setStyle(createBoldStyle(9)); frame.addElement(staticText); staticText = createStaticText("Name", 111, 0); staticText.setStyle(createBoldStyle(9)); frame.addElement(staticText); staticText = createStaticText("Street", 260, 0); staticText.setStyle(createBoldStyle(9)); frame.addElement(staticText); jasperDesign.setPageHeader(band); // Column header band = new JRDesignBand(); jasperDesign.setColumnHeader(band); // Detail band = new JRDesignBand(); band.setHeight(20); textField = new JRDesignTextField(); textField.setX(0); textField.setY(4); textField.setWidth(50); textField.setHeight(15); textField.setHorizontalAlignment(HorizontalAlignEnum.RIGHT); textField.setStyle(normalStyle); JRDesignExpression expression = new JRDesignExpression(); expression.setText("$F{Id}"); textField.setExpression(expression); band.addElement(textField); textField = new JRDesignTextField(); textField.setStretchWithOverflow(true); textField.setX(55); textField.setY(4); textField.setWidth(200); textField.setHeight(15); textField.setPositionType(PositionTypeEnum.FLOAT); textField.setStyle(normalStyle); band.addElement(textField); textField = new JRDesignTextField(); textField.setStretchWithOverflow(true); textField.setX(260); textField.setY(4); textField.setWidth(255); textField.setHeight(15); textField.setPositionType(PositionTypeEnum.FLOAT); textField.setStyle(normalStyle); band.addElement(textField); line = new JRDesignLine(); line.setX(0); line.setY(19); line.setWidth(515); line.setHeight(0); line.setForecolor(new Color(0x80, 0x80, 0x80)); line.setPositionType(PositionTypeEnum.FLOAT); band.addElement(line); ((JRDesignSection) jasperDesign.getDetailSection()).addBand(band); // Column footer band = new JRDesignBand(); // jasperDesign.setColumnFooter(band); // Page footer band = new JRDesignBand(); // jasperDesign.setPageFooter(band); // Summary band = new JRDesignBand(); // jasperDesign.setSummary(band); return jasperDesign; }