//Variables
JRDesignVariable variable = new JRDesignVariable();
variable.setName("CityNumber");
variable.setValueClass(java.lang.Integer.class);
variable.setResetType(ResetTypeEnum.GROUP);
JRDesignGroup group = new JRDesignGroup();
group.setName("CityGroup");
variable.setResetGroup(group);
variable.setCalculation(CalculationEnum.SYSTEM);
JRDesignExpression expression = new JRDesignExpression();
expression.setValueClass(java.lang.Integer.class);
expression.setText("($V{CityNumber} != null)?(new Integer($V{CityNumber}.intValue() + 1)):(new Integer(1))");
variable.setInitialValueExpression(expression);
jasperDesign.addVariable(variable);
variable = new JRDesignVariable();
variable.setName("AllCities");
variable.setValueClass(java.lang.String.class);
variable.setResetType(ResetTypeEnum.REPORT);
variable.setCalculation(CalculationEnum.SYSTEM);
jasperDesign.addVariable(variable);
//Groups
group.setMinHeightToStartNewPage(60);
expression = new JRDesignExpression();
expression.setValueClass(java.lang.String.class);
expression.setText("$F{City}");
group.setExpression(expression);
JRDesignBand band = new JRDesignBand();
band.setHeight(20);
JRDesignTextField textField = new JRDesignTextField();
textField.setX(0);
textField.setY(4);
textField.setWidth(515);
textField.setHeight(15);
textField.setBackcolor(new Color(0xC0, 0xC0, 0xC0));
textField.setMode(ModeEnum.OPAQUE);
textField.setHorizontalAlignment(HorizontalAlignEnum.LEFT);
textField.setStyle(boldStyle);
expression = new JRDesignExpression();
expression.setValueClass(java.lang.String.class);
expression.setText("\" \" + String.valueOf($V{CityNumber}) + \". \" + String.valueOf($F{City})");
textField.setExpression(expression);
band.addElement(textField);
JRDesignLine line = new JRDesignLine();
line.setX(0);
line.setY(19);
line.setWidth(515);
line.setHeight(0);
band.addElement(line);
((JRDesignSection)group.getGroupHeaderSection()).addBand(band);
band = new JRDesignBand();
band.setHeight(20);
line = new JRDesignLine();
line.setX(0);
line.setY(-1);
line.setWidth(515);
line.setHeight(0);
band.addElement(line);
JRDesignStaticText staticText = new JRDesignStaticText();
staticText.setX(400);
staticText.setY(0);
staticText.setWidth(60);
staticText.setHeight(15);
staticText.setHorizontalAlignment(HorizontalAlignEnum.RIGHT);
staticText.setStyle(boldStyle);
staticText.setText("Count : ");
band.addElement(staticText);
textField = new JRDesignTextField();
textField.setX(460);
textField.setY(0);
textField.setWidth(30);
textField.setHeight(15);
textField.setHorizontalAlignment(HorizontalAlignEnum.RIGHT);
textField.setStyle(boldStyle);
expression = new JRDesignExpression();
expression.setValueClass(java.lang.Integer.class);
expression.setText("$V{CityGroup_COUNT}");
textField.setExpression(expression);
band.addElement(textField);
((JRDesignSection)group.getGroupFooterSection()).addBand(band);
jasperDesign.addGroup(group);
//Title
band = new JRDesignBand();