/** * */ public LineSpacingEnum getLineSpacing(JRParagraph paragraph) { LineSpacingEnum ownLineSpacing = paragraph.getOwnLineSpacing(); if (ownLineSpacing != null) { return ownLineSpacing; } JRStyle baseStyle = getBaseStyle(paragraph); if (baseStyle != null) { LineSpacingEnum lineSpacing = baseStyle.getParagraph().getLineSpacing(); if (lineSpacing != null) { return lineSpacing; } } return LineSpacingEnum.SINGLE;//FIXMENOW could we make all enums in default props? }
public void setPropertyValue(Object id, Object value) { JRBaseParagraph jrElement = (JRBaseParagraph) getValue(); if (jrElement != null) { if (id.equals(JRBaseParagraph.PROPERTY_LINE_SPACING)) jrElement.setLineSpacing((LineSpacingEnum) lineSpacingD.getEnumValue(value)); if (id.equals(JRBaseParagraph.PROPERTY_LINE_SPACING_SIZE)) jrElement.setLineSpacingSize((Float) value); if (id.equals(JRBaseParagraph.PROPERTY_FIRST_LINE_INDENT)) jrElement.setFirstLineIndent((Integer) value); if (id.equals(JRBaseParagraph.PROPERTY_LEFT_INDENT)) jrElement.setLeftIndent((Integer) value); if (id.equals(JRBaseParagraph.PROPERTY_RIGHT_INDENT)) jrElement.setRightIndent((Integer) value); if (id.equals(JRBaseParagraph.PROPERTY_SPACING_BEFORE)) jrElement.setSpacingBefore((Integer) value); if (id.equals(JRBaseParagraph.PROPERTY_SPACING_AFTER)) jrElement.setSpacingAfter((Integer) value); if (id.equals(JRBaseParagraph.PROPERTY_TAB_STOP_WIDTH)) jrElement.setTabStopWidth((Integer) value); if (id.equals(JRBaseParagraph.PROPERTY_TAB_STOPS)) { jrElement.addTabStop(null); } } }
@Override public void test() { super.test(); numberOfPagesTest(1); JRStyle style = getElementAt("title.textField1", 0).getStyle(); Assert.assertEquals("line spacing", LineSpacingEnum.DOUBLE, style.getParagraph().getLineSpacing()); Assert.assertEquals("line spacing size", new Float(2), style.getParagraph().getLineSpacingSize()); Assert.assertEquals("first line indent", new Integer(10), style.getParagraph().getFirstLineIndent()); Assert.assertEquals("left indent", new Integer(15), style.getParagraph().getLeftIndent()); Assert.assertEquals("right indent", new Integer(20), style.getParagraph().getRightIndent()); Assert.assertEquals("spacing before", new Integer(5), style.getParagraph().getSpacingBefore()); Assert.assertEquals("spacing after", new Integer(6), style.getParagraph().getSpacingAfter()); Assert.assertEquals("tab stop width", new Integer(9), style.getParagraph().getTabStopWidth()); TabStop[] tabStops = style.getParagraph().getTabStops(); Assert.assertNotNull("tab stops", tabStops); Assert.assertEquals("tab stop position", 12, tabStops[0].getPosition()); Assert.assertEquals("tab stop alignment", TabStopAlignEnum.CENTER, tabStops[0].getAlignment()); }
@Override public void setLineSpacing(LineSpacingEnum lineSpacing) { Object old = this.lineSpacing; this.lineSpacing = lineSpacing; getEventSupport().firePropertyChange(PROPERTY_LINE_SPACING, old, this.lineSpacing); }
@Override public List getTagList() { List tags = new java.util.ArrayList(); tags.add(new Tag(LineSpacingEnum.SINGLE.getValueByte(), I18n.getString("Global.Property.Single"))); tags.add(new Tag(LineSpacingEnum.ONE_AND_HALF.getValueByte(), I18n.getString("Global.Property.1.5"))); tags.add(new Tag(LineSpacingEnum.DOUBLE.getValueByte(), I18n.getString("Global.Property.Double"))); tags.add(new Tag(LineSpacingEnum.AT_LEAST.getValueByte(), I18n.getString("Global.Property.LineSpacingAtLeast"))); tags.add(new Tag(LineSpacingEnum.FIXED.getValueByte(), I18n.getString("Global.Property.LineSpacingFixed"))); tags.add(new Tag(LineSpacingEnum.PROPORTIONAL.getValueByte(), I18n.getString("Global.Property.LineSpacingProportional"))); return tags; }
@Override public boolean canWrite() { LineSpacingEnum val = style.getParagraph().getLineSpacing(); return val != null && val != LineSpacingEnum.DOUBLE && val != LineSpacingEnum.ONE_AND_HALF && val != LineSpacingEnum.SINGLE; }
@Override public boolean canWrite() { LineSpacingEnum val = element.getParagraph().getLineSpacing(); return val != null && val != LineSpacingEnum.DOUBLE && val != LineSpacingEnum.ONE_AND_HALF && val != LineSpacingEnum.SINGLE; }
@Override public LineSpacingEnum getLineSpacing() { return getStyleResolver().getLineSpacing(this); }
@Override public LineSpacingEnum getOwnLineSpacing() { return lineSpacing; }
@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) { horizontalAlignmentValue = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getByValue(horizontalAlignment); verticalAlignmentValue = net.sf.jasperreports.engine.type.VerticalAlignEnum.getByValue(verticalAlignment); rotationValue = RotationEnum.getByValue(rotation); lineSpacingValue = LineSpacingEnum.getByValue(lineSpacing); horizontalAlignment = null; verticalAlignment = null; rotation = null; lineSpacing = null; } if (isStyledText != null) { markup = isStyledText.booleanValue() ? JRCommonText.MARKUP_STYLED_TEXT : JRCommonText.MARKUP_NONE; isStyledText = null; } if (paragraph == null) { paragraph = new JRBaseParagraph(this); paragraph.setLineSpacing(lineSpacingValue); lineSpacingValue = null; } if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_5_5_2) { fontsize = fontSize == null ? null : fontSize.floatValue(); fontSize = null; } if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_6_0_2) { horizontalTextAlign = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getHorizontalTextAlignEnum(horizontalAlignmentValue); verticalTextAlign = net.sf.jasperreports.engine.type.VerticalAlignEnum.getVerticalTextAlignEnum(verticalAlignmentValue); horizontalAlignmentValue = null; verticalAlignmentValue = null; } }
@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) { horizontalAlignmentValue = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getByValue(horizontalAlignment); verticalAlignmentValue = net.sf.jasperreports.engine.type.VerticalAlignEnum.getByValue(verticalAlignment); rotationValue = RotationEnum.getByValue(rotation); runDirectionValue = RunDirectionEnum.getByValue(runDirection); lineSpacingValue = LineSpacingEnum.getByValue(lineSpacing); horizontalAlignment = null; verticalAlignment = null; rotation = null; lineSpacing = null; } if (isStyledText != null) { markup = isStyledText.booleanValue() ? JRCommonText.MARKUP_STYLED_TEXT : JRCommonText.MARKUP_NONE; isStyledText = null; } if (linkType == null) { linkType = JRHyperlinkHelper.getLinkType(HyperlinkTypeEnum.getByValue(hyperlinkType)); } if (linkTarget == null) { linkTarget = JRHyperlinkHelper.getLinkTarget(HyperlinkTargetEnum.getByValue(hyperlinkTarget)); } if (paragraph == null) { paragraph = new JRBaseParagraph(this); paragraph.setLineSpacing(lineSpacingValue); lineSpacingValue = null; } if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_5_5_2) { fontsize = fontSize == null ? null : fontSize.floatValue(); fontSize = null; } if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_6_0_2) { horizontalTextAlign = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getHorizontalTextAlignEnum(horizontalAlignmentValue); verticalTextAlign = net.sf.jasperreports.engine.type.VerticalAlignEnum.getVerticalTextAlignEnum(verticalAlignmentValue); horizontalAlignmentValue = null; verticalAlignmentValue = null; } }
/** * @deprecated Replaced by {@link JRParagraph#getLineSpacing()}. */ @Override public LineSpacingEnum getLineSpacingValue() { return getParagraph().getLineSpacing(); }
/** * @deprecated Replaced by {@link JRParagraph#getOwnLineSpacing()}. */ @Override public LineSpacingEnum getOwnLineSpacingValue() { return getParagraph().getOwnLineSpacing(); }
/** * @deprecated Replaced by {@link JRParagraph#setLineSpacing(LineSpacingEnum)}. */ @Override public void setLineSpacing(LineSpacingEnum lineSpacing) { getParagraph().setLineSpacing(lineSpacing); }
@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); horizontalAlignmentValue = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getByValue(horizontalAlignment); verticalAlignmentValue = net.sf.jasperreports.engine.type.VerticalAlignEnum.getByValue(verticalAlignment); rotationValue = RotationEnum.getByValue(rotation); lineSpacingValue = LineSpacingEnum.getByValue(lineSpacing); scaleImageValue = ScaleImageEnum.getByValue(scaleImage); fillValue = FillEnum.getByValue(fill); mode = null; horizontalAlignment = null; verticalAlignment = null; rotation = null; lineSpacing = null; scaleImage = null; fill = null; } if (isStyledText != null) { markup = isStyledText.booleanValue() ? JRCommonText.MARKUP_STYLED_TEXT : JRCommonText.MARKUP_NONE; isStyledText = null; } if (paragraph == null) { paragraph = new JRBaseParagraph(this); paragraph.setLineSpacing(lineSpacingValue); lineSpacingValue = null; } if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_5_5_2) { fontsize = fontSize == null ? null : fontSize.floatValue(); fontSize = null; } if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_6_0_2) { horizontalTextAlign = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getHorizontalTextAlignEnum(horizontalAlignmentValue); verticalTextAlign = net.sf.jasperreports.engine.type.VerticalAlignEnum.getVerticalTextAlignEnum(verticalAlignmentValue); horizontalImageAlign = net.sf.jasperreports.engine.type.HorizontalAlignEnum.getHorizontalImageAlignEnum(horizontalAlignmentValue); verticalImageAlign = net.sf.jasperreports.engine.type.VerticalAlignEnum.getVerticalImageAlignEnum(verticalAlignmentValue); horizontalAlignmentValue = null; verticalAlignmentValue = null; } }
@Override public Object createObject(Attributes atts) { JRDesignTextElement textElement = (JRDesignTextElement)digester.peek(); HorizontalTextAlignEnum horizontalTextAlign = HorizontalTextAlignEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_textAlignment)); if (horizontalTextAlign != null) { textElement.setHorizontalTextAlign(horizontalTextAlign); } VerticalTextAlignEnum verticalTextAlign = VerticalTextAlignEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_verticalAlignment)); if (verticalTextAlign != null) { textElement.setVerticalTextAlign(verticalTextAlign); } RotationEnum rotation = RotationEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_rotation)); if (rotation != null) { textElement.setRotation(rotation); } LineSpacingEnum lineSpacing = LineSpacingEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_lineSpacing)); if (lineSpacing != null) { if (log.isWarnEnabled()) { log.warn("The 'lineSpacing' attribute is deprecated. Use the <paragraph> tag instead."); } textElement.getParagraph().setLineSpacing(lineSpacing); } textElement.setMarkup(atts.getValue(JRXmlConstants.ATTRIBUTE_markup)); String isStyledText = atts.getValue(JRXmlConstants.ATTRIBUTE_isStyledText); if (isStyledText != null && isStyledText.length() > 0) { if (log.isWarnEnabled()) { log.warn("The 'isStyledText' attribute is deprecated. Use the 'markup' attribute instead."); } textElement.setMarkup(Boolean.valueOf(isStyledText) ? JRCommonText.MARKUP_STYLED_TEXT : JRCommonText.MARKUP_NONE); } return textElement; }
public static void setParagraphAttributes(Attributes atts, JRParagraph paragraph) { LineSpacingEnum lineSpacing = LineSpacingEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_lineSpacing)); if (lineSpacing != null) { paragraph.setLineSpacing(lineSpacing); } String lineSpacingSize = atts.getValue(JRXmlConstants.ATTRIBUTE_lineSpacingSize); if (lineSpacingSize != null && lineSpacingSize.length() > 0) { paragraph.setLineSpacingSize(Float.parseFloat(lineSpacingSize)); } String firstLineIndent = atts.getValue(JRXmlConstants.ATTRIBUTE_firstLineIndent); if (firstLineIndent != null && firstLineIndent.length() > 0) { paragraph.setFirstLineIndent(Integer.parseInt(firstLineIndent)); } String leftIndent = atts.getValue(JRXmlConstants.ATTRIBUTE_leftIndent); if (leftIndent != null && leftIndent.length() > 0) { paragraph.setLeftIndent(Integer.parseInt(leftIndent)); } String rightIndent = atts.getValue(JRXmlConstants.ATTRIBUTE_rightIndent); if (rightIndent != null && rightIndent.length() > 0) { paragraph.setRightIndent(Integer.parseInt(rightIndent)); } String spacingBefore = atts.getValue(JRXmlConstants.ATTRIBUTE_spacingBefore); if (spacingBefore != null && spacingBefore.length() > 0) { paragraph.setSpacingBefore(Integer.parseInt(spacingBefore)); } String spacingAfter = atts.getValue(JRXmlConstants.ATTRIBUTE_spacingAfter); if (spacingAfter != null && spacingAfter.length() > 0) { paragraph.setSpacingAfter(Integer.parseInt(spacingAfter)); } String tabStopWidth = atts.getValue(JRXmlConstants.ATTRIBUTE_tabStopWidth); if (tabStopWidth != null && tabStopWidth.length() > 0) { paragraph.setTabStopWidth(Integer.parseInt(tabStopWidth)); } }
/** * @deprecated Replaced by {@link #getLineSpacing(JRParagraph)}. */ public static LineSpacingEnum getLineSpacingValue(JRCommonText element) { return getLineSpacing(element.getParagraph()); }
/** * @deprecated Replaced by {@link #getLineSpacing(JRParagraph)}. */ public static LineSpacingEnum getLineSpacingValue(JRStyle style) { return getLineSpacing(style.getParagraph()); }
/** * */ public static LineSpacingEnum getLineSpacing(JRParagraph paragraph) { return styleResolver.getLineSpacing(paragraph); }
protected void exportStyledText(JRPrintText printText, JRStyledText styledText, String tooltip, boolean hyperlinkStarted) throws IOException { Locale locale = getTextLocale(printText); LineSpacingEnum lineSpacing = printText.getParagraph().getLineSpacing(); Float lineSpacingSize = printText.getParagraph().getLineSpacingSize(); float lineSpacingFactor = printText.getLineSpacingFactor(); Color backcolor = printText.getBackcolor(); String text = styledText.getText(); int runLimit = 0; addSearchAttributes(styledText, printText); AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator(); boolean first = true; boolean startedSpan = false; boolean highlightStarted = false; while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length()) { //if there are several text runs, write the tooltip into a parent <span> if (first && runLimit < styledText.length() && tooltip != null) { startedSpan = true; writer.write("<span title=\""); writer.write(JRStringUtil.xmlEncode(tooltip)); writer.write("\">"); //reset the tooltip so that inner <span>s to not use it tooltip = null; } first = false; Map<Attribute,Object> attributes = iterator.getAttributes(); Color highlightColor = (Color) attributes.get(JRTextAttribute.SEARCH_HIGHLIGHT); if (highlightColor != null && !highlightStarted) { highlightStarted = true; writer.write("<span class=\"jr_search_result\">"); } else if (highlightColor == null && highlightStarted) { highlightStarted = false; writer.write("</span>"); } exportStyledTextRun( attributes, text.substring(iterator.getIndex(), runLimit), tooltip, locale, lineSpacing, lineSpacingSize, lineSpacingFactor, backcolor, hyperlinkStarted ); iterator.setIndex(runLimit); } if (highlightStarted) { writer.write("</span>"); } if (startedSpan) { writer.write("</span>"); } }
@Override public LineSpacingEnum getLineSpacing() { return lineSpacing; }
@Override public LineSpacingEnum getOwnLineSpacing() { return base.getOwnLineSpacing(); }
@Override public void setLineSpacing(LineSpacingEnum lineSpacing) { throw new UnsupportedOperationException(); }
@Override public void createPropertyDescriptors(List<IPropertyDescriptor> desc, Map<String, Object> defaultsMap) { lineSpacingD = new JSSEnumPropertyDescriptor(JRBaseParagraph.PROPERTY_LINE_SPACING, Messages.common_line_spacing, LineSpacingEnum.class, NullEnum.INHERITED); lineSpacingD.setDescription(Messages.MTextElement_line_spacing_description); desc.add(lineSpacingD); FloatPropertyDescriptor lineSpacingSize = new FloatPropertyDescriptor(JRBaseParagraph.PROPERTY_LINE_SPACING_SIZE, Messages.MParagraph_lineSpacingSizeTitle); lineSpacingSize.setDescription(Messages.MParagraph_lineSpacingSizeDescription); desc.add(lineSpacingSize); PixelPropertyDescriptor firstLineIdent = new PixelPropertyDescriptor( JRBaseParagraph.PROPERTY_FIRST_LINE_INDENT, Messages.MParagraph_firstIdentTitle); firstLineIdent.setDescription(Messages.MParagraph_firstIdentDescription); desc.add(firstLineIdent); PixelPropertyDescriptor leftIdent = new PixelPropertyDescriptor(JRBaseParagraph.PROPERTY_LEFT_INDENT, Messages.MParagraph_leftIdentTitle); leftIdent.setDescription(Messages.MParagraph_leftIdentDescription); desc.add(leftIdent); PixelPropertyDescriptor rightIdent = new PixelPropertyDescriptor(JRBaseParagraph.PROPERTY_RIGHT_INDENT, Messages.MParagraph_rightIdentTitle); rightIdent.setDescription(Messages.MParagraph_rightIdentDescription); desc.add(rightIdent); PixelPropertyDescriptor spacingBefore = new PixelPropertyDescriptor(JRBaseParagraph.PROPERTY_SPACING_BEFORE, Messages.MParagraph_spacingBeforeTitle); spacingBefore.setDescription(Messages.MParagraph_spacingBeforeDescription); desc.add(spacingBefore); PixelPropertyDescriptor spacingAfter = new PixelPropertyDescriptor(JRBaseParagraph.PROPERTY_SPACING_AFTER, Messages.MParagraph_spacingAfterTitle); spacingAfter.setDescription(Messages.MParagraph_spacingAfterDescription); desc.add(spacingAfter); PixelPropertyDescriptor tabStopWidth = new PixelPropertyDescriptor(JRBaseParagraph.PROPERTY_TAB_STOP_WIDTH, Messages.MParagraph_tabStopWidthTitle); tabStopWidth.setDescription(Messages.MParagraph_tabStopWidthDescription); desc.add(tabStopWidth); TabStopsPropertyDescriptor tabStops = new TabStopsPropertyDescriptor(JRBaseParagraph.PROPERTY_TAB_STOPS, Messages.MParagraph_tabStopsTitle); tabStops.setDescription(Messages.MParagraph_tabStopsDescription); desc.add(tabStops); tabStops.setCategory("Paragraph"); //$NON-NLS-1$ lineSpacingD.setCategory("Paragraph"); //$NON-NLS-1$ lineSpacingSize.setCategory("Paragraph"); //$NON-NLS-1$ firstLineIdent.setCategory("Paragraph"); //$NON-NLS-1$ leftIdent.setCategory("Paragraph"); //$NON-NLS-1$ rightIdent.setCategory("Paragraph"); //$NON-NLS-1$ spacingBefore.setCategory("Paragraph"); //$NON-NLS-1$ spacingAfter.setCategory("Paragraph"); //$NON-NLS-1$ tabStopWidth.setCategory("Paragraph"); //$NON-NLS-1$ setHelpPrefix(desc, "net.sf.jasperreports.doc/docs/schema.reference.html?cp=0_1#paragraph"); //$NON-NLS-1$ }
@Override public void setByte(Byte lineSpacing) { style.getParagraph().setLineSpacing(LineSpacingEnum.getByValue(lineSpacing)); }
@Override public void setByte(Byte lineSpacing) { element.getParagraph().setLineSpacing(LineSpacingEnum.getByValue(lineSpacing)); }
/** * @deprecated Replaced by {@link JRParagraph#getLineSpacing()}. */ public LineSpacingEnum getLineSpacingValue();
/** * @deprecated Replaced by {@link JRParagraph#getOwnLineSpacing()}. */ public LineSpacingEnum getOwnLineSpacingValue();
/** * @deprecated Replaced by {@link JRParagraph#setLineSpacing(LineSpacingEnum)} */ public void setLineSpacing(LineSpacingEnum lineSpacing);
/** * Gets the text line spacing. * @return a value representing one of the line spacing constants in {@link LineSpacingEnum} */ public LineSpacingEnum getLineSpacing();
/** * Gets the text own line spacing. * @return a value representing one of the line spacing constants in {@link LineSpacingEnum} */ public LineSpacingEnum getOwnLineSpacing();
/** * Sets the text line spacing. * @param lineSpacing a value representing one of the line spacing constants in {@link LineSpacingEnum} */ public void setLineSpacing(LineSpacingEnum lineSpacing);