@Override public Object createObject(Attributes atts) { TabStop tabStop = new TabStop(); String position = atts.getValue(JRXmlConstants.ATTRIBUTE_position); if (position != null && position.length() > 0) { tabStop.setPosition(Integer.parseInt(position)); } TabStopAlignEnum alignment = TabStopAlignEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_alignment)); if (alignment != null) { tabStop.setAlignment(alignment); } return tabStop; }
/** * */ public TabStop[] getTabStops(JRParagraph paragraph) { TabStop[] ownTabStops = paragraph.getOwnTabStops(); if (ownTabStops != null) { return ownTabStops; } JRStyle style = getBaseStyle(paragraph); if (style != null) { TabStop[] tabStops = style.getParagraph().getTabStops(); if (tabStops != null) { return tabStops; } } return null; }
@Override public String getId() { StringBuilder sb = new StringBuilder(); sb.append(verticalAlignment).append("|").append(horizontalAlignment) .append("|").append(runDirection).append("|").append(textRotation) .append("|").append(paragraph.getLineSpacing().getName()) .append("|").append(paragraph.getLineSpacingSize()) .append("|").append(paragraph.getFirstLineIndent()) .append("|").append(paragraph.getLeftIndent()) .append("|").append(paragraph.getRightIndent()) .append("|").append(paragraph.getSpacingBefore()) .append("|").append(paragraph.getSpacingAfter()); // + "|" + tabStopWidth;// tabStopWidth can only be set in default-style TabStop[] tabStops = paragraph.getTabStops(); if (tabStops != null && tabStops.length > 0) { for (int i = 0; i < tabStops.length; i++) { TabStop tabStop = tabStops[i]; sb.append("|").append(tabStop.getPosition()).append("|").append(tabStop.getAlignment().getName()); } } return sb.toString(); }
public void setValue(Object val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { //if (!(val instanceof JRPropertiesMap)) throw new IllegalArgumentException(); if (!(val instanceof List)) throw new IllegalArgumentException(); // Fill this map with the content of the map we got here... // 1. Create the map... List values = (List)val; // Remove all the tab stops... if (style.getParagraph().getTabStops() != null) { for (int k=style.getParagraph().getTabStops().length-1; k>= 0; --k) { style.getParagraph().removeTabStop(0); } } for (int i=0; i <values.size(); ++i) { TabStop prop = (TabStop)values.get(i); style.getParagraph().addTabStop(prop); } com.jaspersoft.ireport.designer.IReportManager.getInstance().notifyReportChange(); }
public void setValue(Object val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { //if (!(val instanceof JRPropertiesMap)) throw new IllegalArgumentException(); if (!(val instanceof List)) throw new IllegalArgumentException(); // Fill this map with the content of the map we got here... // 1. Create the map... List values = (List)val; // Remove all the tab stops... if (element.getParagraph().getTabStops() != null) { for (int k=element.getParagraph().getTabStops().length-1; k>= 0; --k) { element.getParagraph().removeTabStop(0); } } for (int i=0; i <values.size(); ++i) { TabStop prop = (TabStop)values.get(i); element.getParagraph().addTabStop(prop); } com.jaspersoft.ireport.designer.IReportManager.getInstance().notifyReportChange(); }
public List getTabStops() { List<TabStop> tabStops = new ArrayList<TabStop>(); DefaultTableModel dtm = (DefaultTableModel)jTableProperties.getModel(); for (int i=0; i<dtm.getRowCount(); ++i) { if (dtm.getValueAt(i, 0) != null) { tabStops.add( new TabStop( (Integer)dtm.getValueAt(i, 0) , TabStopAlignEnum.getByValue( (Byte)dtm.getValueAt(i, 1) ))); } } return tabStops; }
@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 TabStop[] getOwnTabStops() { if (tabStops == null || tabStops.size() == 0) { return null; } return tabStops.toArray(new TabStop[tabStops.size()]); }
@Override public void addTabStop(TabStop tabStop) { if (tabStops == null) { tabStops = new ArrayList<TabStop>(); } tabStops.add(tabStop); getEventSupport().fireCollectionElementAddedEvent(PROPERTY_TAB_STOPS, tabStop, tabStops.size() - 1); }
@Override public void addTabStop(int index, TabStop tabStop) { if (tabStops == null) { tabStops = new ArrayList<TabStop>(); } tabStops.add(index, tabStop); getEventSupport().fireCollectionElementAddedEvent(PROPERTY_TAB_STOPS, tabStop, index); }
@Override public void removeTabStop(TabStop tabStop) { if (tabStops != null) { int index = tabStops.indexOf(tabStop); if (index >= 0) { tabStops.remove(index); getEventSupport().fireCollectionElementRemovedEvent(PROPERTY_TAB_STOPS, tabStop, index); } } }
@Override public void removeTabStop(int index) { if (tabStops != null) { if (index >= 0 && index < tabStops.size()) { TabStop tabStop = tabStops.remove(index); getEventSupport().fireCollectionElementRemovedEvent(PROPERTY_TAB_STOPS, tabStop, index); } } }
protected RuleSet readRuleSet() { return new RuleSetBase() { @Override public void addRuleInstances(Digester digester) { digester.addObjectCreate(PATTERN_ROOT, JRSimpleTemplate.class); digester.addCallMethod(PATTERN_INCLUDED_TEMPLATE, "addIncludedTemplate", 0); digester.addFactoryCreate(PATTERN_STYLE, JRTemplateStyleFactory.class); digester.addSetNext(PATTERN_STYLE, "addStyle", JRStyle.class.getName()); digester.addFactoryCreate(PATTERN_STYLE_PEN, JRPenFactory.Style.class.getName()); digester.addFactoryCreate(PATTERN_BOX, JRBoxFactory.class.getName()); digester.addFactoryCreate(PATTERN_BOX_PEN, JRPenFactory.Box.class.getName()); digester.addFactoryCreate(PATTERN_BOX_TOP_PEN, JRPenFactory.Top.class.getName()); digester.addFactoryCreate(PATTERN_BOX_LEFT_PEN, JRPenFactory.Left.class.getName()); digester.addFactoryCreate(PATTERN_BOX_BOTTOM_PEN, JRPenFactory.Bottom.class.getName()); digester.addFactoryCreate(PATTERN_BOX_RIGHT_PEN, JRPenFactory.Right.class.getName()); digester.addFactoryCreate(PATTERN_PARAGRAPH, JRParagraphFactory.class.getName()); digester.addFactoryCreate(PATTERN_TAB_STOP, TabStopFactory.class.getName()); digester.addSetNext(PATTERN_TAB_STOP, "addTabStop", TabStop.class.getName()); } }; }
/** * */ public void writeParagraph(JRParagraph paragraph, XmlNamespace namespace) throws IOException { if (paragraph != null && isNewerVersionOrEqual(JRConstants.VERSION_4_0_2)) { writer.startElement(JRXmlConstants.ELEMENT_paragraph, namespace); writer.addAttribute(JRXmlConstants.ATTRIBUTE_lineSpacing, paragraph.getOwnLineSpacing()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_lineSpacingSize, paragraph.getOwnLineSpacingSize()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_firstLineIndent, paragraph.getOwnFirstLineIndent()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_leftIndent, paragraph.getOwnLeftIndent()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_rightIndent, paragraph.getOwnRightIndent()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_spacingBefore, paragraph.getOwnSpacingBefore()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_spacingAfter, paragraph.getOwnSpacingAfter()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_tabStopWidth, paragraph.getOwnTabStopWidth()); /* */ TabStop[] tabStops = paragraph.getTabStops(); if (tabStops != null && tabStops.length > 0) { for(int i = 0; i < tabStops.length; i++) { writeTabStop(tabStops[i]); } } writer.closeElement(true); } }
/** * */ public void writeTabStop(TabStop tabStop) throws IOException { if (tabStop != null) { writer.startElement(JRXmlConstants.ELEMENT_tabStop); writer.addAttribute(JRXmlConstants.ATTRIBUTE_position, tabStop.getPosition()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_alignment, tabStop.getAlignment()); writer.closeElement(true); } }
/** * */ public static float getRightX(TabStop tabStop, float advance) { float rightX = advance; if (tabStop != null) { switch (tabStop.getAlignment()) { case RIGHT ://FIXMETAB RTL writings { rightX = tabStop.getPosition(); break; } case CENTER : { rightX = tabStop.getPosition() + advance / 2; break; } case LEFT : default : { rightX = tabStop.getPosition() + advance; } } } return rightX; }
/** * */ public static float getLeftX(TabStop tabStop, float advance) { float leftX = 0; if (tabStop != null) { switch (tabStop.getAlignment()) { case RIGHT ://FIXMETAB RTL writings { leftX = tabStop.getPosition() - advance; break; } case CENTER : { leftX = tabStop.getPosition() - advance / 2; break; } case LEFT : default : { leftX = tabStop.getPosition(); } } } return leftX; }
/** * */ public static float getSegmentOffset(TabStop tabStop, float rightX) { float segmentOffset = rightX; if (tabStop != null) { switch (tabStop.getAlignment()) { case RIGHT ://FIXMETAB RTL writings { segmentOffset = rightX; break; } case CENTER : { segmentOffset = rightX; break; } case LEFT : default : { segmentOffset = tabStop.getPosition(); } } } return segmentOffset; }
/** * */ protected void writeParagraph(JRParagraph paragraph, String paragraphHolder) { if (paragraph != null) { String paragraphName = paragraphHolder + "Paragraph"; write( "JRParagraph " + paragraphName + " = " + paragraphHolder + ".getParagraph();\n"); write( paragraphName + ".setLineSpacing({0});\n", paragraph.getOwnLineSpacing()); write( paragraphName + ".setLineSpacingSize({0});\n", paragraph.getOwnLineSpacingSize()); write( paragraphName + ".setFirstLineIndent({0});\n", paragraph.getOwnFirstLineIndent()); write( paragraphName + ".setLeftIndent({0});\n", paragraph.getOwnLeftIndent()); write( paragraphName + ".setRightIndent({0});\n", paragraph.getOwnRightIndent()); write( paragraphName + ".setSpacingBefore({0});\n", paragraph.getOwnSpacingBefore()); write( paragraphName + ".setSpacingAfter({0});\n", paragraph.getOwnSpacingAfter()); write( paragraphName + ".setTabStopWidth(Integer.valueOf({0, number, #}));\n", paragraph.getOwnTabStopWidth());//FIXMENOW is this pattern needed? TabStop[] tabStops = paragraph.getTabStops(); if (tabStops != null && tabStops.length > 0) { for(int i = 0; i < tabStops.length; i++) { writeTabStop( tabStops[i], paragraphName + "TabStop" + i); write( paragraphName +".addTabStop(" + paragraphName + "TabStop" + i + ");\n"); } } flush(); } }
/** * */ private void writeTabStop(TabStop tabStop, String tabStopName) { if (tabStop != null) { write( "TabStop " + tabStopName + " = new TabStop();\n"); write( tabStopName + ".setAlignment({0});\n", tabStop.getAlignment(), TabStopAlignEnum.LEFT); write( tabStopName + ".setPosition({0});\n", tabStop.getPosition()); flush(); } }
/** * */ private void exportTabStops(JRParagraph paragraph) { TabStop[] tabStops = paragraph.getTabStops(); if (tabStops != null && tabStops.length > 0) { write(" <w:tabs>\n"); for (int i = 0; i < tabStops.length; i++) { TabStop tabStop = tabStops[i]; write(" <w:tab w:pos=\"" + LengthUtil.twip(tabStop.getPosition()) + "\" w:val=\"" + getTabStopAlignment(tabStop.getAlignment()) + "\"/>\n"); } write(" </w:tabs>\n"); } }
/** * @throws IOException * */ private void exportParagraph(JRParagraph paragraph) throws IOException { if (paragraph != null) { xmlWriter.startElement(JRXmlConstants.ELEMENT_paragraph); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_lineSpacing, paragraph.getOwnLineSpacing()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_lineSpacingSize, paragraph.getOwnLineSpacingSize()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_firstLineIndent, paragraph.getOwnFirstLineIndent()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_leftIndent, paragraph.getOwnLeftIndent()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_rightIndent, paragraph.getOwnRightIndent()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_spacingBefore, paragraph.getOwnSpacingBefore()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_spacingAfter, paragraph.getOwnSpacingAfter()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_tabStopWidth, paragraph.getOwnTabStopWidth()); /* */ TabStop[] tabStops = paragraph.getTabStops(); if (tabStops != null && tabStops.length > 0) { for(int i = 0; i < tabStops.length; i++) { exportTabStop(tabStops[i]); } } xmlWriter.closeElement(true); } }
/** * */ public void exportTabStop(TabStop tabStop) throws IOException { if (tabStop != null) { xmlWriter.startElement(JRXmlConstants.ELEMENT_tabStop); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_position, tabStop.getPosition()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_alignment, tabStop.getAlignment()); xmlWriter.closeElement(true); } }
protected void truncateLastLineAtChar( TextLineWrapper lineWrapper, String paragraphText, int paragraphOffset ) { //truncate the original line at char measuredState = prevMeasuredState.cloneState(); lineWrapper.startParagraph(measuredState.textOffset, paragraphOffset + paragraphText.length(), true); //render again the last line //if the line does not fit now, it will remain empty renderNextLine(lineWrapper, null, new int[]{0}, new TabStop[]{null}, new boolean[]{false}); }
public String getColumnText(Object element, int columnIndex) { TabStop tabstop = (TabStop) element; switch (columnIndex) { case 0: return Integer.toString(tabstop.getPosition()); case 1: return tabstop.getAlignment().getName(); } return ""; //$NON-NLS-1$ }
public void setValue(List<TabStop> value) { this.value = value; if (value == null) { value = new ArrayList<TabStop>(); } if (table != null) fillTable(table, value); }
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(2, false); composite.setLayout(layout); setControl(composite); buildTable(composite); GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 400; table.setLayoutData(gd); Composite bGroup = new Composite(composite, SWT.NONE); bGroup.setLayout(new GridLayout(1, false)); bGroup.setLayoutData(new GridData(GridData.FILL_VERTICAL)); new NewButton().createNewButtons(bGroup, tableViewer, new INewElement() { public Object newElement(List<?> input, int pos) { TabStop p = new TabStop(); p.setPosition(20); p.setAlignment(TabStopAlignEnum.LEFT); return p; } }); new DeleteButton().createDeleteButton(bGroup, tableViewer); new ListOrderButtons().createOrderButtons(bGroup, tableViewer); }
@Override protected Object openDialogBox(Control cellEditorWindow) { TabStopsEditor wizard = new TabStopsEditor(); wizard.setValue((List<TabStop>) getValue()); WizardDialog dialog = new WizardDialog(cellEditorWindow.getShell(), wizard); dialog.create(); if (dialog.open() == Dialog.OK) { return wizard.getValue(); } return null; }
public Object getPropertyValue(Object id) { JRBaseParagraph jrElement = (JRBaseParagraph) getValue(); if (jrElement != null) { if (id.equals(JRBaseParagraph.PROPERTY_LINE_SPACING)) return lineSpacingD.getEnumValue(jrElement.getOwnLineSpacing()); if (id.equals(JRBaseParagraph.PROPERTY_LINE_SPACING_SIZE)) return jrElement.getOwnLineSpacingSize(); if (id.equals(JRBaseParagraph.PROPERTY_FIRST_LINE_INDENT)) return jrElement.getOwnFirstLineIndent(); if (id.equals(JRBaseParagraph.PROPERTY_LEFT_INDENT)) return jrElement.getOwnLeftIndent(); if (id.equals(JRBaseParagraph.PROPERTY_RIGHT_INDENT)) return jrElement.getOwnRightIndent(); if (id.equals(JRBaseParagraph.PROPERTY_SPACING_BEFORE)) return jrElement.getOwnSpacingBefore(); if (id.equals(JRBaseParagraph.PROPERTY_SPACING_AFTER)) return jrElement.getOwnSpacingAfter(); if (id.equals(JRBaseParagraph.PROPERTY_TAB_STOP_WIDTH)) return jrElement.getOwnTabStopWidth(); if (id.equals(JRBaseParagraph.PROPERTY_TAB_STOPS)) { TabStop[] tabStops = jrElement.getTabStops(); if (tabStops != null) return Arrays.asList(tabStops); return new ArrayList<TabStop>(); } } return null; }
public Object getValue() throws IllegalAccessException, InvocationTargetException { TabStop[] tabStops = style.getParagraph().getTabStops(); List<TabStop> tabStopsList = new ArrayList<TabStop>(); if (tabStops != null) { tabStopsList.addAll( Arrays.asList(tabStops) ); } return tabStopsList; }
public Object getValue() throws IllegalAccessException, InvocationTargetException { TabStop[] tabStops = element.getParagraph().getTabStops(); List<TabStop> tabStopsList = new ArrayList<TabStop>(); if (tabStops != null) { tabStopsList.addAll( Arrays.asList(tabStops) ); } return tabStopsList; }
public void setTabStops(List<TabStop> tabStops) { DefaultTableModel dtm = (DefaultTableModel)jTableProperties.getModel(); dtm.setRowCount(0); for (TabStop tabStop : tabStops) { Vector row = new Vector(); row.addElement( tabStop.getPosition()); row.addElement( tabStop.getAlignment().getValueByte() ); dtm.addRow(row); } }
@Override public TabStop[] getTabStops() { return getStyleResolver().getTabStops(this); }
/** * */ public static TabStop[] getTabStops(JRParagraph paragraph) { return styleResolver.getTabStops(paragraph); }
@Override public TabStop[] getTabStops() { return base.getTabStops(); }
@Override public TabStop[] getOwnTabStops() { return base.getOwnTabStops(); }
@Override public void addTabStop(TabStop tabStop) { throw new UnsupportedOperationException(); }
@Override public void addTabStop(int index, TabStop tabStop) { throw new UnsupportedOperationException(); }
@Override public void removeTabStop(TabStop tabStop) { throw new UnsupportedOperationException(); }
/** * */ protected boolean renderParagraph( TextLineWrapper lineWrapper, int lastParagraphStart, String lastParagraphText ) { if (lastParagraphText == null) { lineWrapper.startEmptyParagraph(lastParagraphStart); } else { lineWrapper.startParagraph(lastParagraphStart, lastParagraphStart + lastParagraphText.length(), false); } List<Integer> tabIndexes = JRStringUtil.getTabIndexes(lastParagraphText); int[] currentTabHolder = new int[]{0}; TabStop[] nextTabStopHolder = new TabStop[]{null}; boolean[] requireNextWordHolder = new boolean[]{false}; measuredState.paragraphStartLine = measuredState.lines; measuredState.textOffset = lastParagraphStart; boolean rendered = true; boolean renderedLine = false; // the paragraph is measured one line at a time while (lineWrapper.paragraphPosition() < lineWrapper.paragraphEnd() && rendered) { rendered = renderNextLine(lineWrapper, tabIndexes, currentTabHolder, nextTabStopHolder, requireNextWordHolder); renderedLine = renderedLine || rendered; } //if we rendered at least one line, and the last line didn't fit //and the text does not overflow if (!rendered && prevMeasuredState != null && !canOverflow) { //handle last rendered row processLastTruncatedRow(lineWrapper, lastParagraphText, lastParagraphStart, renderedLine); } return rendered; }