@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 static String getTabStopAlignment(TabStopAlignEnum alignment) { if (alignment != null) { switch (alignment) { case RIGHT : return TAB_STOP_ALIGN_RIGHT; case CENTER : return TAB_STOP_ALIGN_CENTER; case LEFT : default : return TAB_STOP_ALIGN_LEFT; } } return null; }
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()); }
/** * */ 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(); } }
/** * */ public static String getTabStopAlignment(TabStopAlignEnum tabStopAlignment) { switch (tabStopAlignment) { case RIGHT : return TAB_STOP_ALIGN_RIGHT; case CENTER : return TAB_STOP_ALIGN_CENTER; case LEFT : default : return TAB_STOP_ALIGN_LEFT; } }
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); }
public JRTabStopsPropertyCustomEditor (Object value, PropertyEditor editor, PropertyEnv env) { this.env = env; this.editor = editor; this.env.setState(PropertyEnv.STATE_NEEDS_VALIDATION); this.env.addPropertyChangeListener(this); initComponents(); Tag[] tags = new Tag[] { new Tag( TabStopAlignEnum.LEFT.getValueByte(), I18n.getString("AbstractStyleNode.Property.Left") ), new Tag( TabStopAlignEnum.CENTER.getValueByte(), I18n.getString("AbstractStyleNode.Property.Center") ), new Tag( TabStopAlignEnum.RIGHT.getValueByte(), I18n.getString("AbstractStyleNode.Property.Right") ) }; jTableProperties.getColumnModel().getColumn(1).setCellEditor(new ComboBoxEditor(tags)); jTableProperties.getColumnModel().getColumn(1).setCellRenderer(new ComboBoxRenderer(tags)); DefaultListSelectionModel dlsm = (DefaultListSelectionModel)this.jTableProperties.getSelectionModel(); dlsm.addListSelectionListener(new javax.swing.event.ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { jTablePropertiesListSelectionValueChanged(e); } }); if (value instanceof List && value != null) { setTabStops((List)value); } }
private static TabStopAlignment tabStopAlignment(TabStopAlignEnum alignment) { switch (alignment) { case LEFT: return TabStopAlignment.LEFT; case CENTER: return TabStopAlignment.CENTER; case RIGHT: return TabStopAlignment.RIGHT; default: throw new JasperDesignException("TabStopAlignment " + alignment.name() + " not supported"); } }
public static TabStopAlignEnum tabStopAlignment(TabStopAlignment alignment) { switch (alignment) { case LEFT: return TabStopAlignEnum.LEFT; case CENTER: return TabStopAlignEnum.CENTER; case RIGHT: return TabStopAlignEnum.RIGHT; default: throw new JasperDesignException("TabStopAlignment " + alignment.name() + " not supported"); } }
/** * */ public TabStop(int position, TabStopAlignEnum alignment) { this.position = position; this.alignment = alignment; }
/** * Gets the tab stop alignment. */ public TabStopAlignEnum getAlignment() { return alignment; }
/** * Sets the tab stop alignment. */ public void setAlignment(TabStopAlignEnum alignment) { this.alignment = alignment; }
private void jButtonNewPropertyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNewPropertyActionPerformed DefaultTableModel dtm = (DefaultTableModel)jTableProperties.getModel(); Vector row = new Vector(); row.addElement(0); row.addElement( TabStopAlignEnum.LEFT.getValue() ); dtm.addRow(row); }