@Override public void test() { super.test(); numberOfPagesTest(1); JRElement textField = getJasperReport().getTitle().getElementByKey("title.textField1"); Assert.assertEquals("position type", PositionTypeEnum.FIX_RELATIVE_TO_TOP, textField.getPositionTypeValue()); Assert.assertEquals("stretch type", StretchTypeEnum.NO_STRETCH, textField.getStretchTypeValue()); Assert.assertTrue("print in first whole band", textField.isPrintInFirstWholeBand()); Assert.assertTrue("print when detail overflows", textField.isPrintWhenDetailOverflows()); Assert.assertEquals("print when group changes", "group1", textField.getPrintWhenGroupChanges().getName()); textField = getJasperReport().getDetailSection().getBands()[0].getElementByKey("detail.column_column11"); Assert.assertTrue("print when detail overflows", textField.isPrintWhenDetailOverflows()); }
@Override public void setPositionType(PositionTypeEnum positionTypeValue) { PositionTypeEnum old = this.positionTypeValue; this.positionTypeValue = positionTypeValue; getEventSupport().firePropertyChange(PROPERTY_POSITION_TYPE, old, this.positionTypeValue); }
@SuppressWarnings("deprecation") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2) { modeValue = ModeEnum.getByValue(mode); positionTypeValue = PositionTypeEnum.getByValue(positionType); stretchTypeValue = StretchTypeEnum.getByValue(stretchType); mode = null; } }
/** * */ private void writeReportElement(JRElement element) throws IOException { writer.startElement(JRXmlConstants.ELEMENT_reportElement); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_key, element.getKey()); writeStyleReferenceAttr(element); writer.addAttribute(JRXmlConstants.ATTRIBUTE_positionType, element.getPositionTypeValue(), PositionTypeEnum.FIX_RELATIVE_TO_TOP); writeStretchType(element.getStretchTypeValue()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_isPrintRepeatedValues, element.isPrintRepeatedValues(), true); writer.addAttribute(JRXmlConstants.ATTRIBUTE_mode, element.getOwnModeValue()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_x, element.getX()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_y, element.getY()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_width, element.getWidth()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_height, element.getHeight()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_isRemoveLineWhenBlank, element.isRemoveLineWhenBlank(), false); writer.addAttribute(JRXmlConstants.ATTRIBUTE_isPrintInFirstWholeBand, element.isPrintInFirstWholeBand(), false); writer.addAttribute(JRXmlConstants.ATTRIBUTE_isPrintWhenDetailOverflows, element.isPrintWhenDetailOverflows(), false); if (element.getPrintWhenGroupChanges() != null) { writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_printWhenGroupChanges, element.getPrintWhenGroupChanges().getName()); } writer.addAttribute(JRXmlConstants.ATTRIBUTE_forecolor, element.getOwnForecolor()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_backcolor, element.getOwnBackcolor()); if ( isNewerVersionOrEqual(JRConstants.VERSION_4_6_0) && !isExcludeUuids() ) { writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_uuid, element.getUUID().toString()); } writeProperties(element); writePropertyExpressions(element.getPropertyExpressions()); writeExpression(JRXmlConstants.ELEMENT_printWhenExpression, element.getPrintWhenExpression(), false); writer.closeElement(); }
/** * */ protected JRDesignElement(JRDefaultStyleProvider defaultStyleProvider) { super(defaultStyleProvider); positionTypeValue = PositionTypeEnum.FIX_RELATIVE_TO_TOP; }
/** * */ private void setDependentElements() { if (ySortedElements != null && ySortedElements.length > 0) { for(int i = 0; i < ySortedElements.length - 1; i++) { JRFillElement iElem = ySortedElements[i]; boolean isBreakElem = iElem instanceof JRFillBreak; for(int j = i + 1; j < ySortedElements.length; j++) { JRFillElement jElem = ySortedElements[j]; int left = Math.min(iElem.getX(), jElem.getX()); int right = Math.max(iElem.getX() + iElem.getWidth(), jElem.getX() + jElem.getWidth()); if ( ((isBreakElem && jElem.getPositionTypeValue() == PositionTypeEnum.FIX_RELATIVE_TO_TOP) || jElem.getPositionTypeValue() == PositionTypeEnum.FLOAT) && iElem.getY() + iElem.getHeight() <= jElem.getY() && iElem.getWidth() + jElem.getWidth() > right - left // FIXME band bottom elements should not have dependent elements ) { iElem.addDependantElement(jElem); } } /* if (iElem.getParent().getElementGroup() != null) //parent might be null { iElem.setGroupElements( iElem.getParent().getElementGroup().getElements() ); } */ } } }
@Override public List getTagList() { List tags = new java.util.ArrayList(); tags.add(new Tag(PositionTypeEnum.FIX_RELATIVE_TO_TOP, I18n.getString("Global.Property.FixTop"))); tags.add(new Tag(PositionTypeEnum.FLOAT, I18n.getString("Global.Property.PositionFloat"))); tags.add(new Tag(PositionTypeEnum.FIX_RELATIVE_TO_BOTTOM, I18n.getString("Global.Property.FixBottom"))); return tags; }
private static void addColumnHeaderToBand(ODLTableDefinition table, int elementWidth, JRDesignBand chBand) { JRDesignStaticText back = new JRDesignStaticText(); back.setBackcolor(new Color(230, 230, 230)); back.setWidth(elementWidth); back.setHeight(20); back.setMode(ModeEnum.OPAQUE); chBand.addElement(back); List<Double> colWidths = getColumnWidths(table, elementWidth); int nc = table.getColumnCount(); if (nc > 0) { double dx=0; for (int i = 0; i < nc; i++) { JRDesignStaticText text = new JRDesignStaticText(); int x = (int) Math.round(dx); text.setX(x); text.setY(4); text.setWidth((int) Math.floor(colWidths.get(i))); text.setHeight(15); text.setText(table.getColumnName(i)); text.setFontSize(11); // int fs = text.getFontSize(); text.setForecolor(new Color(0, 0, 80)); text.setBold(true); chBand.addElement(text); dx += colWidths.get(i); } } JRDesignLine line = new JRDesignLine(); // line.setX(-ret.getLeftMargin()); line.setY(19); line.setWidth(elementWidth); line.setHeight(0); line.setPositionType(PositionTypeEnum.FLOAT); chBand.addElement(line); }
@Override public PositionTypeEnum getPositionTypeValue() { return positionTypeValue; }
@Override public PositionTypeEnum getPositionTypeValue() { return element.getPositionTypeValue(); }
@Override public void setPositionType(PositionTypeEnum positionType) { throw new UnsupportedOperationException(); }
@Override public PositionTypeEnum getPositionTypeValue() { return parent.getPositionTypeValue();//FIXME optimize this by consolidating style properties }
@SuppressWarnings("unchecked") public PositionTypeProperty(JRDesignElement element) { super(PositionTypeEnum.class, element); this.element = element; }
@Override public Object getDefaultValue() { return PositionTypeEnum.FIX_RELATIVE_TO_TOP; }
@Override public void setPropertyValue(Object positionType) { element.setPositionType((PositionTypeEnum)positionType); }
/** * Returns the position type for the element * @return the position type */ public PositionTypeEnum getPositionTypeValue();
/** * Sets the position type for the element. * @param positionType the position type */ public void setPositionType(PositionTypeEnum positionType);