Java 类net.sf.jasperreports.engine.design.JRDesignTextElement 实例源码

项目:jasperreports    文件:HeaderToolbarElementUtils.java   
public static void copyOwnTextElementStyle(EditTextElementData textElementData, JRDesignTextElement textElement, Locale locale) {
    textElementData.setFontName(textElement.getOwnFontName());
    textElementData.setFontSize(textElement.getOwnFontsize() != null ? NumberFormat.getNumberInstance(locale).format(textElement.getOwnFontsize()) : null);
    textElementData.setFloatFontSize(textElement.getOwnFontsize() != null ? textElement.getOwnFontsize() : null);
    textElementData.setFontBold(textElement.isOwnBold());
    textElementData.setFontItalic(textElement.isOwnItalic());
    textElementData.setFontUnderline(textElement.isOwnUnderline());
    textElementData.setFontColor(textElement.getOwnForecolor() != null ? JRColorUtil.getColorHexa(textElement.getOwnForecolor()) : null);
    textElementData.setFontBackColor(textElement.getOwnBackcolor() != null ? JRColorUtil.getColorHexa(textElement.getOwnBackcolor()) : null);
    textElementData.setFontHAlign(textElement.getOwnHorizontalTextAlign() != null ? textElement.getOwnHorizontalTextAlign().getName() : null);
    textElementData.setMode(textElement.getOwnModeValue() != null ? textElement.getOwnModeValue().getName() : null);

    if (textElement instanceof JRDesignTextField && TableUtil.hasSingleChunkExpression((JRDesignTextField) textElement)) {
        textElementData.setFormatPattern(((JRDesignTextField) textElement).getOwnPattern());
    }
}
项目:jasperreports    文件:HeaderToolbarElementUtils.java   
public static void copyTextElementStyle(EditTextElementData textElementData, JRDesignTextElement textElement, Locale locale) {
    textElementData.setFontName(JRStringUtil.htmlEncode(textElement.getFontName()));
    textElementData.setFontSize(NumberFormat.getNumberInstance(locale).format(textElement.getFontsize()));
    textElementData.setFloatFontSize(textElement.getFontsize());
    textElementData.setFontBold(textElement.isBold());
    textElementData.setFontItalic(textElement.isItalic());
    textElementData.setFontUnderline(textElement.isUnderline());
    textElementData.setFontColor(JRColorUtil.getColorHexa(textElement.getForecolor()));
    textElementData.setFontBackColor(JRColorUtil.getColorHexa(textElement.getBackcolor()));
    textElementData.setFontHAlign(textElement.getHorizontalTextAlign().getName());
    textElementData.setMode(textElement.getModeValue().getName());

    if (textElement instanceof JRDesignTextField && TableUtil.hasSingleChunkExpression((JRDesignTextField) textElement)) {
        textElementData.setFormatPattern(JRStringUtil.htmlEncode(((JRDesignTextField) textElement).getPattern()));
    }
}
项目:jasperreports    文件:HeaderToolbarElementUtils.java   
/**
 * 
 */
public static ConditionalFormattingData getConditionalFormattingData(
    JRDesignTextElement textElement, 
    JasperReportsContext jasperReportsContext
    ) 
{
    ConditionalFormattingData cfd = null;
    if (textElement != null) 
    {
        JRPropertiesMap propertiesMap = textElement.getPropertiesMap();
        if (
            propertiesMap.containsProperty(ConditionalFormattingCommand.COLUMN_CONDITIONAL_FORMATTING_PROPERTY) 
            && propertiesMap.getProperty(ConditionalFormattingCommand.COLUMN_CONDITIONAL_FORMATTING_PROPERTY) != null
            ) 
        {
            cfd = 
                JacksonUtil.getInstance(jasperReportsContext).loadObject(
                    propertiesMap.getProperty(ConditionalFormattingCommand.COLUMN_CONDITIONAL_FORMATTING_PROPERTY), 
                    ConditionalFormattingData.class
                    );
        }
    }
    return cfd;
}
项目:jasperreports    文件:HeaderToolbarElementJsonHandler.java   
private boolean setTextElements(List<GroupCell> groupCells, Map<JRDesignTextElement, GroupInfo> groups, String groupType, Integer columnIndex) {
    boolean result = false;
    if (groupCells != null) {
        for (GroupCell gc: groupCells) {
            JRDesignTextElement textElement = TableUtil.getCellElement(JRDesignTextElement.class, gc.getCell(), false);

            if (textElement != null) {
                result = true;
                if (groups.containsKey(textElement)) {
                    groups.get(textElement).addForColumn(columnIndex);
                }
                else {
                    GroupInfo gi = new GroupInfo(gc.getGroupName() != null ? gc.getGroupName() : groupType + "_" + columnIndex, groupType);
                    gi.addForColumn(columnIndex);
                    groups.put(textElement, gi);
                }
            }
        }
    }
    return result;
}
项目:jasperreports    文件:EditTextElementAction.java   
private JRDesignTextElement getTargetTextElement() {
    EditTextElementData textElementData = getEditTextElementData();
    List<BaseColumn> allCols = TableUtil.getAllColumns(table);
    StandardColumn col = (StandardColumn)allCols.get(textElementData.getColumnIndex());
    JRDesignTextElement result = null;

    if (EditTextElementData.APPLY_TO_DETAIL_ROWS.equals(textElementData.getApplyTo())) {
        result = TableUtil.getCellElement(JRDesignTextElement.class, col.getDetailCell(), true);
    } else if (EditTextElementData.APPLY_TO_GROUP_SUBTOTAL.equals(textElementData.getApplyTo())) {
        result = TableUtil.getCellElement(JRDesignTextElement.class, col, TableUtil.COLUMN_GROUP_FOOTER, textElementData.getGroupName(), table);
    } else if (EditTextElementData.APPLY_TO_HEADING.equals(textElementData.getApplyTo())) {
        result = TableUtil.getCellElement(JRDesignTextElement.class, col.getColumnHeader(), true);
    } else if (EditTextElementData.APPLY_TO_GROUPHEADING.equals(textElementData.getApplyTo())) {
        result = TableUtil.getCellElement(JRDesignTextElement.class, col, TableUtil.COLUMN_GROUP_HEADER, textElementData.getGroupName(), table);
    } else if (EditTextElementData.APPLY_TO_TABLE_TOTAL.equals(textElementData.getApplyTo())) {
        result = TableUtil.getCellElement(JRDesignTextElement.class, col, TableUtil.TABLE_FOOTER, null, table);
    }

    return result;
}
项目:PDFReporter-Studio    文件:MTextElement.java   
@Override
public void setPropertyValue(Object id, Object value) {
    JRDesignTextElement jrElement = (JRDesignTextElement) getValue();
    if (id.equals(JRBaseStyle.PROPERTY_MARKUP))
        jrElement.setMarkup((String) value);

    else if (id.equals(JRBaseStyle.PROPERTY_HORIZONTAL_ALIGNMENT))
        jrElement.setHorizontalAlignment((HorizontalAlignEnum) hAlignD.getEnumValue(value));
    else if (id.equals(JRBaseStyle.PROPERTY_VERTICAL_ALIGNMENT)) {
        VerticalAlignEnum va = (VerticalAlignEnum) EnumHelper.getSetValue(VerticalAlignEnum.values(), value, 1, true);
        if (va != null && va.equals(VerticalAlignEnum.JUSTIFIED))
            va = VerticalAlignEnum.MIDDLE;
        jrElement.setVerticalAlignment(va);
    } else if (id.equals(JRBaseStyle.PROPERTY_ROTATION))
        jrElement.setRotation((RotationEnum) rotationD.getEnumValue(value));

    getMFont().setPropertyValue(id, value);

    super.setPropertyValue(id, value);
}
项目:ireport-fork    文件:TextElementPropertiesFactory.java   
/**
 * Convenient way to get all the properties of an element.
 * Properties positions could be reordered to have a better order.
 */
public static List<Sheet.Set> getPropertySets(JRDesignElement element, JasperDesign jd)
{
    List<Sheet.Set> sets = new ArrayList<Sheet.Set>();

    if (element instanceof  JRDesignStaticText)
    {
        sets.add( getStaticTextPropertySet((JRDesignStaticText)element, jd ));
    }
    else if (element instanceof  JRDesignTextField)
    {
        sets.add( getTextFieldPropertySet((JRDesignTextField)element, jd ));
    }

    if (element instanceof  JRDesignTextElement)
    {
        sets.add( getTextPropertySet((JRDesignTextElement)element, jd) );
    }

    return sets;
}
项目:ireport-fork    文件:ReportTextElementInplaceEditorProvider.java   
private Font getElementFont(Widget widget)
{

    JRDesignTextElement element = getTextElement(widget);
    Scene scene = widget.getScene();
    if (element != null)
    {
       int style = Font.PLAIN;
       if (element.isBold()) style |= Font.BOLD;
       if (element.isItalic()) style |= Font.ITALIC;

       float size = ((float) element.getFontSize() * (float) scene.getZoomFactor());
       if (size < 5f) size = 5f;

       Font textFont = new Font(element.getFontName(), style, (int)size);
       textFont = textFont.deriveFont(size);
       return textFont;
    }

    if (scene.getZoomFactor() > 1.0)
    {
        Font font = scene.getDefaultFont();
        font = font.deriveFont((float) (font.getSize2D() * scene.getZoomFactor()));
    }
    return null;
}
项目:ireport-fork    文件:ReportTextElementInplaceEditorProvider.java   
private float getElementHorizontalAlignment(Widget widget)
{
    JRDesignTextElement element = getTextElement(widget);
    if (element != null)
    {
        switch (element.getHorizontalAlignmentValue())
        {
                case CENTER:
                    return JTextArea.CENTER_ALIGNMENT;
                case LEFT:
                    return JTextArea.LEFT_ALIGNMENT;
                case RIGHT:
                    return JTextArea.RIGHT_ALIGNMENT;
                //case JRAlignment.HORIZONTAL_ALIGN_JUSTIFIED:
                //    return JTextArea.;
        }
    }
    return JTextArea.LEFT_ALIGNMENT;
}
项目:ireport-fork    文件:ReportTextElementInplaceEditorProvider.java   
private float getElementVerticalAlignment(Widget widget)
{
    JRDesignTextElement element = getTextElement(widget);
    if (element != null)
    {
        switch (element.getVerticalAlignmentValue())
        {
                case MIDDLE:
                    return JTextArea.CENTER_ALIGNMENT;
                case TOP:
                    return JTextArea.TOP_ALIGNMENT;
                case BOTTOM:
                    return JTextArea.BOTTOM_ALIGNMENT;
                //case JRAlignment.VERTICAL_ALIGN_JUSTIFIED:
                //    return JTextArea.;
        }
    }
    return JTextArea.TOP_ALIGNMENT;
}
项目:ireport-fork    文件:TransformElementAction.java   
private void copyTextProperties(JRDesignTextElement element, JRDesignTextElement newElement) {
    newElement.setBold( element.isOwnBold() );
    newElement.setItalic( element.isOwnItalic());
    newElement.setFontName( element.getOwnFontName());
    newElement.setFontSize( element.getOwnFontSize());
    newElement.setHorizontalAlignment( element.getOwnHorizontalAlignmentValue());
    newElement.setLineSpacing( element.getOwnLineSpacingValue());
    newElement.setMarkup(element.getMarkup());
    newElement.setPdfEmbedded( element.isOwnPdfEmbedded());
    newElement.setPdfEncoding( element.getOwnPdfEncoding());
    newElement.setPdfFontName( element.getOwnPdfFontName());
    newElement.setRotation( element.getOwnRotationValue());
    newElement.setStrikeThrough( element.isOwnStrikeThrough());
    newElement.setVerticalAlignment( element.getOwnVerticalAlignmentValue());
    newElement.setUnderline(element.isOwnUnderline());
}
项目:ireport-fork    文件:TextElementsToolbar.java   
private void jButtonIncreaseFontActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonIncreaseFontActionPerformed
    if (getSelectedTextElements().size() > 0)
    {
        boolean isFirstUndo = true;
        for (JRDesignTextElement element : getSelectedTextElements())
        {
            // TODO: add undo operation...
            int newFontSize = element.getFontSize() + 2;
            Integer oldFontSize = element.getOwnFontSize();
            element.setFontSize(newFontSize);
            ObjectPropertyUndoableEdit opUndo = new ObjectPropertyUndoableEdit(element, "FontSize",Integer.class, oldFontSize , new Integer(newFontSize));
            IReportManager.getInstance().addUndoableEdit(opUndo, !isFirstUndo);
            isFirstUndo = false;
        }
    }
}
项目:ireport-fork    文件:TextElementsToolbar.java   
private void jButtonDecreaseFontActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDecreaseFontActionPerformed
    if (getSelectedTextElements().size() > 0)
    {
        boolean isFirstUndo = true;
        for (JRDesignTextElement element : getSelectedTextElements())
        {
            // TODO: add undo operation...
            int newFontSize = element.getFontSize() -2;
            if (newFontSize >= 3)
            {
                Integer oldFontSize = element.getOwnFontSize();
                element.setFontSize(newFontSize);
                ObjectPropertyUndoableEdit opUndo = new ObjectPropertyUndoableEdit(element, "FontSize",Integer.class, oldFontSize , new Integer(newFontSize));
                IReportManager.getInstance().addUndoableEdit(opUndo, !isFirstUndo);
                isFirstUndo = false;
            }
        }
    }
}
项目:ireport-fork    文件:TextElementsToolbar.java   
private void jToggleButtonItalicItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jToggleButtonItalicItemStateChanged
    if (isInit()) return;
    boolean oldChanging = isChanging();
    setChanging(true);

    if (getSelectedTextElements().size() > 0)
    {
        boolean isFirstUndo = true;
        boolean newValue = jToggleButtonItalic.isSelected();
        for (JRDesignTextElement element : getSelectedTextElements())
        {
            // TODO: add undo operation...

            if (newValue != element.isItalic())
            {
                Boolean oldValue = element.isOwnItalic();
                element.setItalic(newValue);
                ObjectPropertyUndoableEdit opUndo = new ObjectPropertyUndoableEdit(element, "Italic",Boolean.class, oldValue , new Boolean(newValue));
                IReportManager.getInstance().addUndoableEdit(opUndo, !isFirstUndo);
                isFirstUndo = false;
            }
        }
    }

    setChanging(oldChanging);
}
项目:ireport-fork    文件:TextElementsToolbar.java   
private void jToggleButtonUnderlineItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jToggleButtonUnderlineItemStateChanged
    if (isInit()) return;
    boolean oldChanging = isChanging();
    setChanging(true);

    if (getSelectedTextElements().size() > 0)
    {
        boolean isFirstUndo = true;
        boolean newValue = jToggleButtonUnderline.isSelected();
        for (JRDesignTextElement element : getSelectedTextElements())
        {
            // TODO: add undo operation...
            if (newValue != element.isUnderline())
            {
                Boolean oldValue = element.isOwnUnderline();
                element.setUnderline(newValue);
                ObjectPropertyUndoableEdit opUndo = new ObjectPropertyUndoableEdit(element, "Underline",Boolean.class, oldValue , new Boolean(newValue));
                IReportManager.getInstance().addUndoableEdit(opUndo, !isFirstUndo);
                isFirstUndo = false;
            }
        }
    }

    setChanging(oldChanging);
}
项目:ireport-fork    文件:TextElementsToolbar.java   
private void jToggleButtonStriketroughtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonStriketroughtActionPerformed
    if (isInit()) return;
    boolean oldChanging = isChanging();
    setChanging(true);

    if (getSelectedTextElements().size() > 0)
    {
        boolean isFirstUndo = true;
        boolean newValue = jToggleButtonStriketrought.isSelected();
        for (JRDesignTextElement element : getSelectedTextElements())
        {
            // TODO: add undo operation...
            if (newValue != element.isStrikeThrough())
            {
                Boolean oldValue = element.isOwnStrikeThrough();
                element.setStrikeThrough(newValue);
                ObjectPropertyUndoableEdit opUndo = new ObjectPropertyUndoableEdit(element, "StrikeThrough",Boolean.class, oldValue , new Boolean(newValue));
                IReportManager.getInstance().addUndoableEdit(opUndo, !isFirstUndo);
                isFirstUndo = false;
            }
        }
    }

    setChanging(oldChanging);
}
项目:ireport-fork    文件:TextElementsToolbar.java   
private void modifyHorizontalAlignment() {
    if (isInit()) return;
    boolean oldChanging = isChanging();
    setChanging(true);

    if (getSelectedTextElements().size() > 0)
    {
        boolean isFirstUndo = true;
        HorizontalAlignEnum newValue = getSelectedHorizontalAlignment();
        for (JRDesignTextElement element : getSelectedTextElements())
        {
            // TODO: add undo operation...
            if ((newValue == null && element.getOwnHorizontalAlignmentValue() != null) || (newValue != null && newValue != element.getHorizontalAlignmentValue()))
            {
                HorizontalAlignEnum oldValue = element.getOwnHorizontalAlignmentValue();
                element.setHorizontalAlignment(newValue);
                ObjectPropertyUndoableEdit opUndo = new ObjectPropertyUndoableEdit(element, "HorizontalAlignment",HorizontalAlignEnum.class, oldValue , newValue);
                IReportManager.getInstance().addUndoableEdit(opUndo, !isFirstUndo);
                isFirstUndo = false;
            }
        }
    }

    setChanging(oldChanging);
}
项目:ireport-fork    文件:TextElementsToolbar.java   
private void fontSizeSelected() {

    if (isInit()) return;
    boolean oldChanging = isChanging();
    setChanging(true);

    boolean isFirstUndo = true;
    if (getSelectedTextElements().size() > 0)
    {
        int newFontSize = (int)((JNumberComboBox)jComboBoxFontSize).getValue();

        for (JRDesignTextElement element : getSelectedTextElements())
        {
            // TODO: add undo operation...
            if (element.getFontSize() != newFontSize)
            {
                Integer oldFontSize = element.getOwnFontSize();
                element.setFontSize(newFontSize);
                ObjectPropertyUndoableEdit opUndo = new ObjectPropertyUndoableEdit(element, "FontSize",Integer.class, oldFontSize , new Integer(newFontSize));
                IReportManager.getInstance().addUndoableEdit(opUndo, !isFirstUndo);
                isFirstUndo = false;
            }
        }
    }
    setChanging(oldChanging);
}
项目:jasperreports    文件:HeaderToolbarElementJsonHandler.java   
private void setColumnHeaderData(String sortColumnLabel, Integer columnIndex, CommandTarget target, Map<String, Object> contextMap,
        JasperReportsContext jasperReportsContext, ReportContext reportContext, Locale locale) {
    if (target != null){
        JRIdentifiable identifiable = target.getIdentifiable();
        JRDesignComponentElement componentElement = identifiable instanceof JRDesignComponentElement ? (JRDesignComponentElement)identifiable : null;
        StandardTable table = componentElement == null ? null : (StandardTable)componentElement.getComponent();

        List<BaseColumn> tableColumns = TableUtil.getAllColumns(table);

        if (columnIndex != null) {
            StandardColumn column = (StandardColumn) tableColumns.get(columnIndex);

            JRDesignTextElement textElement = TableUtil.getCellElement(JRDesignTextElement.class, column.getColumnHeader(), true);

            if (textElement != null) {
                EditTextElementData textElementData = new EditTextElementData();

                textElementData.setHeadingName(JRStringUtil.htmlEncode(sortColumnLabel));
                textElementData.setColumnIndex(columnIndex);
                JRDesignTextElement styledElement = resolveElementStyle(textElement, reportContext, target);
                HeaderToolbarElementUtils.copyTextElementStyle(textElementData, styledElement, locale);

                contextMap.put("colHeaderData", JacksonUtil.getInstance(jasperReportsContext).getJsonString(textElementData));
            }
        }
    }
}
项目:jasperreports    文件:HeaderToolbarElementJsonHandler.java   
private EditTextElementData setColumnValueData(Integer columnIndex, CommandTarget target, Map<String, Object> contextMap,
        JasperReportsContext jasperReportsContext, ReportContext reportContext, Locale locale) {
    EditTextElementData textElementData = new EditTextElementData();

    if (target != null){
        JRIdentifiable identifiable = target.getIdentifiable();
        JRDesignComponentElement componentElement = identifiable instanceof JRDesignComponentElement ? (JRDesignComponentElement)identifiable : null;
        StandardTable table = componentElement == null ? null : (StandardTable)componentElement.getComponent();

        List<BaseColumn> tableColumns = TableUtil.getAllColumns(table);

        if (columnIndex != null) {
            StandardColumn column = (StandardColumn) tableColumns.get(columnIndex);

            JRDesignTextField textElement = TableUtil.getCellElement(JRDesignTextField.class, column.getDetailCell(), true);

            if (textElement != null) {
                textElementData.setColumnIndex(columnIndex);
                JRDesignTextElement styledElement = resolveElementStyle(textElement, reportContext, target);
                HeaderToolbarElementUtils.copyTextElementStyle(textElementData, styledElement, locale);
            }
        }
    }
    contextMap.put("colValueData", JacksonUtil.getInstance(jasperReportsContext).getJsonString(textElementData));

    return textElementData;
}
项目:jasperreports    文件:EditTextElementCommand.java   
private void applyColumnHeaderData(EditTextElementData textElementData, JRDesignTextElement textElement, boolean execute) {
    if (EditTextElementData.APPLY_TO_HEADING.equals(textElementData.getApplyTo())) {
        if (textElement instanceof JRDesignTextField) {
            JRDesignTextField designTextField = (JRDesignTextField)textElement;
            if (execute) {
                if (oldText == null) {
                    oldText = (designTextField.getExpression()).getText();
                }
                ((JRDesignExpression)designTextField.getExpression()).setText("\"" + JRStringUtil.escapeJavaStringLiteral(textElementData.getHeadingName()) + "\"");
            } else {
                ((JRDesignExpression)designTextField.getExpression()).setText(oldText);
            }

        } else if (textElement instanceof JRDesignStaticText){
            JRDesignStaticText staticText = (JRDesignStaticText)textElement;
            if (execute) {
                if (oldText == null) {
                    oldText = staticText.getText();
                }
                staticText.setText(textElementData.getHeadingName());
            } else {
                staticText.setText(oldText);
            }
        }
    }

    textElement.setFontName(textElementData.getFontName());
    textElement.setFontSize(textElementData.getFloatFontSize());
    textElement.setBold(textElementData.getFontBold());
    textElement.setItalic(textElementData.getFontItalic());
    textElement.setUnderline(textElementData.getFontUnderline());
    textElement.setForecolor(textElementData.getFontColor() != null ? JRColorUtil.getColor("#" + textElementData.getFontColor(), textElement.getForecolor()) : null);
    textElement.setHorizontalTextAlign(HorizontalTextAlignEnum.getByName(textElementData.getFontHAlign()));
    textElement.setBackcolor(textElementData.getFontBackColor() != null ? JRColorUtil.getColor("#" + textElementData.getFontBackColor(), Color.white) : null);
    textElement.setMode(ModeEnum.getByName(textElementData.getMode()));

    if (textElement instanceof JRDesignTextField && TableUtil.hasSingleChunkExpression((JRDesignTextField) textElement)) {
        ((JRDesignTextField) textElement).setPattern(textElementData.getFormatPattern());
    }
}
项目:PDFReporter-Studio    文件:ApplyCrosstabStyleAction.java   
/**
 * 
 * Apply the list of styles to the cell of the crosstab. The styles are first set to null and then at
 * the style value, to force a graphical update (the style are not update if the name is the same)
 * 
 * @param styleList list of styles that will be applied on the crosstab, the order is important
 * and it should be: crosstab header, group, total and detail
 */
private void setCellStyles(List<JRDesignStyle> styleList) {
    JRDesignCrosstab crosstab = (JRDesignCrosstab) getElement();
    List<JRDesignCellContents> contents = ModelUtils.getAllCells(crosstab);
    for (JRDesignCellContents content : contents) 
    {
        if (content == null) continue;
        JRDesignStyle style = getCellBackgroundColor(crosstab, content.getOrigin(), styleList);
        if (style != null) {
            try {
                content.setStyle(null);
                content.setStyle(style);
                content.setMode(ModeEnum.OPAQUE);
                // Set the text white if the background color its color is
                // too similar to the background
                Color backGround = style.getBackcolor();
                int luminance = (30 * backGround.getRed() + 59
                        * backGround.getGreen() + 11 * backGround.getBlue()) / 255;
                if (luminance < 50) {
                    JRElement[] elements = content.getElements();
                    for (int i = 0; i < elements.length; ++i) {
                        if (elements[i] instanceof JRDesignTextElement) {
                            ((JRDesignTextElement) elements[i])
                                    .setForecolor(Color.WHITE);
                        }
                    }
                }
            } catch (NullPointerException e) {
            }
        }
    }
}
项目:PDFReporter-Studio    文件:MTextElement.java   
@Override
public Object getPropertyActualValue(Object id) {
    JRDesignTextElement jrElement = (JRDesignTextElement) getValue();

    if (id.equals(JRDesignStyle.PROPERTY_MARKUP))
        return jrElement.getMarkup();

    if (id.equals(PARAGRAPH)) {
        if (mParagraph == null) {
            mParagraph = new MParagraph(this, (JRBaseParagraph) jrElement.getParagraph());
            setChildListener(mParagraph);
        }
        return mParagraph;
    }

    if (id.equals(JRBaseStyle.PROPERTY_HORIZONTAL_ALIGNMENT))
        return hAlignD.getEnumValue(jrElement.getHorizontalAlignmentValue());
    if (id.equals(JRBaseStyle.PROPERTY_VERTICAL_ALIGNMENT))
        return vAlignD.getEnumValue(jrElement.getVerticalAlignmentValue());
    if (id.equals(JRBaseStyle.PROPERTY_ROTATION))
        return rotationD.getEnumValue(jrElement.getRotationValue());

    if (getMFont() != null) {
        Object val = tFont.getPropertyActualValue(id);
        if (val != null)
            return val;
    }

    return super.getPropertyActualValue(id);
}
项目:PDFReporter-Studio    文件:MTextElement.java   
@Override
public Object getPropertyValue(Object id) {
    JRDesignTextElement jrElement = (JRDesignTextElement) getValue();

    if (id.equals(JRDesignStyle.PROPERTY_MARKUP))
        return jrElement.getOwnMarkup();

    if (id.equals(PARAGRAPH)) {
        if (mParagraph == null) {
            mParagraph = new MParagraph(this, (JRBaseParagraph) jrElement.getParagraph());
            setChildListener(mParagraph);
        }
        return mParagraph;
    }

    if (id.equals(JRBaseStyle.PROPERTY_HORIZONTAL_ALIGNMENT)){
        if (hAlignD == null) getPropertyDescriptors();
        return hAlignD.getEnumValue(jrElement.getOwnHorizontalAlignmentValue());
    }
    if (id.equals(JRBaseStyle.PROPERTY_VERTICAL_ALIGNMENT)){
        if (vAlignD == null) getPropertyDescriptors();
        return vAlignD.getEnumValue(jrElement.getOwnVerticalAlignmentValue());
    }
    if (id.equals(JRBaseStyle.PROPERTY_ROTATION)){
        if (rotationD == null) getPropertyDescriptors();
        return rotationD.getEnumValue(jrElement.getOwnRotationValue());
    }

    if (getMFont() != null) {
        Object val = tFont.getPropertyValue(id);
        if (val != null)
            return val;
    }

    return super.getPropertyValue(id);
}
项目:PDFReporter-Studio    文件:MTextElement.java   
@Override
public void trasnferProperties(JRElement target){
    super.trasnferProperties(target);
    JRDesignTextElement jrSource = (JRDesignTextElement) getValue();
    JRDesignTextElement jrTarget = (JRDesignTextElement)target;

    jrTarget.setHorizontalAlignment(jrSource.getOwnHorizontalAlignmentValue());
    jrTarget.setVerticalAlignment(jrSource.getOwnVerticalAlignmentValue());
    jrTarget.setMarkup(getStringClone(jrSource.getOwnMarkup()));
    jrTarget.setRotation(jrSource.getOwnRotationValue());

    jrTarget.setBold(jrSource.isOwnBold());
    jrTarget.setItalic(jrSource.isOwnItalic());
    jrTarget.setUnderline(jrSource.isOwnUnderline());
    jrTarget.setStrikeThrough(jrSource.isOwnStrikeThrough());
    jrTarget.setPdfEmbedded(jrSource.isOwnPdfEmbedded());
    jrTarget.setFontName(getStringClone(jrSource.getOwnFontName()));
    jrTarget.setFontSize(jrSource.getOwnFontsize());
    jrTarget.setPdfFontName(getStringClone(jrSource.getOwnPdfFontName()));
    jrTarget.setPdfEncoding(getStringClone(jrSource.getOwnPdfEncoding()));

    JRBaseParagraph jrTargetParagraph = (JRBaseParagraph)jrTarget.getParagraph();
    JRBaseParagraph jrSourceParagraph = (JRBaseParagraph) jrSource.getParagraph();
    if (jrTargetParagraph != null && jrSourceParagraph != null){
        jrTargetParagraph.setLineSpacing(jrSourceParagraph.getOwnLineSpacing());
        jrTargetParagraph.setLineSpacingSize(jrSourceParagraph.getOwnLineSpacingSize());
        jrTargetParagraph.setFirstLineIndent(jrSourceParagraph.getOwnFirstLineIndent());
        jrTargetParagraph.setLeftIndent(jrSourceParagraph.getOwnLeftIndent());
        jrTargetParagraph.setRightIndent(jrSourceParagraph.getOwnRightIndent());
        jrTargetParagraph.setSpacingAfter(jrSourceParagraph.getOwnSpacingAfter());
        jrTargetParagraph.setSpacingBefore(jrTargetParagraph.getOwnSpacingBefore());
        jrTargetParagraph.setTabStopWidth(jrSourceParagraph.getOwnTabStopWidth());
    }
}
项目:PDFReporter-Studio    文件:UpdateStyleCommand.java   
/**
 * Create the command to apply the textual style to an element
 * 
 * @param element a textual element
 * @param newStyle The new styles to apply to the textual element
 */
public UpdateStyleCommand(MTextElement element, TextStyle newStyle){
    this.jrElement = (JRDesignTextElement)element.getValue();
    this.newStyleTemplate = newStyle;
    this.elementModel = element;
    oldStyle = null;
}
项目:PDFReporter-Studio    文件:UpdateStyleCommand.java   
/**
 * Apply the passed style to the stored jrElement reference
 * 
 * @param style the style to apply
 */
public static void applayStyleToTextElement(TextStyle style, JRDesignTextElement element){
    element.setHorizontalAlignment(style.getHorizontalAlignmen());
    element.setVerticalAlignment(style.getVerticalAlignmen());
    element.setRotation(style.getRotation());
    element.setBackcolor(style.getBackGroundColor());
    element.setForecolor(style.getForeGroundColor());
    element.setMode(style.isTransparent() ? ModeEnum.TRANSPARENT : ModeEnum.OPAQUE);
    JRFont font = style.getFont();
    element.setFontName(font.getOwnFontName());
    element.setFontSize(font.getOwnFontsize());
    element.setBold(font.isOwnBold());
    element.setItalic(font.isOwnItalic());
    element.setUnderline(font.isOwnUnderline());
    element.setStrikeThrough(font.isOwnStrikeThrough());
    JRLineBox sourceLineBox = style.getBorders();
    if (sourceLineBox != null){
        JRLineBox destLineBox = element.getLineBox();
        destLineBox.setPadding(sourceLineBox.getOwnPadding());
        destLineBox.setLeftPadding(sourceLineBox.getOwnLeftPadding());
        destLineBox.setRightPadding(sourceLineBox.getOwnRightPadding());
        destLineBox.setTopPadding(sourceLineBox.getOwnTopPadding());
        destLineBox.setBottomPadding(sourceLineBox.getOwnBottomPadding());
        setPenValues(sourceLineBox.getPen(), destLineBox.getPen());
        setPenValues(sourceLineBox.getLeftPen(), destLineBox.getLeftPen());
        setPenValues(sourceLineBox.getRightPen(), destLineBox.getRightPen());
        setPenValues(sourceLineBox.getBottomPen(), destLineBox.getBottomPen());
        setPenValues(sourceLineBox.getTopPen(), destLineBox.getTopPen());
    }
}
项目:PDFReporter-Studio    文件:CustomStyleResolver.java   
private static void copyInheritedTextualAttributes(JRDesignElement target, JRStyle style){
    JRDesignTextElement jrTarget = (JRDesignTextElement)target;

    if (jrTarget.getOwnHorizontalAlignmentValue() == null) jrTarget.setHorizontalAlignment(style.getHorizontalAlignmentValue());
    if (jrTarget.getOwnVerticalAlignmentValue() == null) jrTarget.setVerticalAlignment(style.getVerticalAlignmentValue());
    if (jrTarget.getOwnVerticalAlignmentValue() == null) jrTarget.setMarkup(getMarkup(style));
    if (jrTarget.getOwnRotationValue() == null) jrTarget.setRotation(style.getRotationValue());

    if (jrTarget.isOwnBold() == null) jrTarget.setBold(style.isBold());
    if (jrTarget.isOwnItalic() == null) jrTarget.setItalic(style.isItalic());
    if (jrTarget.isOwnUnderline() == null) jrTarget.setUnderline(style.isUnderline());
    if (jrTarget.isOwnStrikeThrough() == null) jrTarget.setStrikeThrough(style.isStrikeThrough());
    if (jrTarget.isOwnPdfEmbedded() == null) jrTarget.setPdfEmbedded(style.isPdfEmbedded());
    if (jrTarget.getOwnFontName() == null) jrTarget.setFontName(getFontName(style));
    if (jrTarget.getOwnFontsize() == null) jrTarget.setFontSize(style.getFontsize());
    if (jrTarget.getOwnPdfFontName() == null) jrTarget.setPdfFontName(getPdfFontName(style));
    if (jrTarget.getOwnPdfEncoding() == null) jrTarget.setPdfEncoding(getPdfEncoding(style));

    JRBaseParagraph jrTargetParagraph = (JRBaseParagraph)jrTarget.getParagraph();
    JRBaseParagraph jrStyleParagraph = (JRBaseParagraph) style.getParagraph();
    if (jrTargetParagraph != null && jrStyleParagraph != null){
        if (jrTargetParagraph.getOwnLineSpacing() == null) jrTargetParagraph.setLineSpacing(jrStyleParagraph.getLineSpacing());
        if (jrTargetParagraph.getOwnLineSpacingSize() == null) jrTargetParagraph.setLineSpacingSize(jrStyleParagraph.getLineSpacingSize());
        if (jrTargetParagraph.getOwnFirstLineIndent() == null) jrTargetParagraph.setFirstLineIndent(jrStyleParagraph.getFirstLineIndent());
        if (jrTargetParagraph.getOwnLeftIndent() == null) jrTargetParagraph.setLeftIndent(jrStyleParagraph.getLeftIndent());
        if (jrTargetParagraph.getOwnRightIndent() == null) jrTargetParagraph.setRightIndent(jrStyleParagraph.getRightIndent());
        if (jrTargetParagraph.getOwnSpacingAfter() == null) jrTargetParagraph.setSpacingAfter(jrStyleParagraph.getSpacingAfter());
        if (jrTargetParagraph.getOwnSpacingBefore() == null) jrTargetParagraph.setSpacingBefore(jrStyleParagraph.getSpacingBefore());
        if (jrTargetParagraph.getOwnTabStopWidth() == null) jrTargetParagraph.setTabStopWidth(jrStyleParagraph.getTabStopWidth());
    }
}
项目:ireport-fork    文件:ElementNode.java   
public ElementNode(JasperDesign jd, JRDesignElement element, Children children, Index index, Lookup doLkp)
{
    super (children, index, new ProxyLookup( doLkp, Lookups.fixed(jd,element)));
    elemenNameVisitor = new ElementNameVisitor(jd);
    this.jd = jd;
    this.element = element;

    element.getEventSupport().addPropertyChangeListener(this);

    IReportManager.getPreferences().addPreferenceChangeListener(new WeakPreferenceChangeListener(this,IReportManager.getInstance().getPreferences()));

    if (element instanceof JRDesignGraphicElement)
    {
        JRDesignGraphicElement gele = (JRDesignGraphicElement)element;
        ((JRBasePen)gele.getLinePen()).getEventSupport().addPropertyChangeListener(this);
    }

    if (element instanceof JRBoxContainer)
    {
        JRBoxContainer boxcontainer = (JRBoxContainer)element;
        JRBaseLineBox baseBox = (JRBaseLineBox)boxcontainer.getLineBox();
        baseBox.getEventSupport().addPropertyChangeListener(this);
        ((JRBasePen)baseBox.getPen()).getEventSupport().addPropertyChangeListener(this);
        ((JRBasePen)baseBox.getTopPen()).getEventSupport().addPropertyChangeListener(this);
        ((JRBasePen)baseBox.getBottomPen()).getEventSupport().addPropertyChangeListener(this);
        ((JRBasePen)baseBox.getLeftPen()).getEventSupport().addPropertyChangeListener(this);
        ((JRBasePen)baseBox.getRightPen()).getEventSupport().addPropertyChangeListener(this);
    }

    if (element instanceof JRDesignTextElement)
    {
        ((JRBaseParagraph)((JRDesignTextElement)element).getParagraph()).getEventSupport().addPropertyChangeListener(this);

    }

}
项目:ireport-fork    文件:ReportTextElementInplaceEditorProvider.java   
private JRDesignTextElement getTextElement(Widget widget) {

    if (widget instanceof JRDesignElementWidget)
    {
        JRDesignElement element = ((JRDesignElementWidget)widget).getElement();
        if (element instanceof JRDesignTextElement) return (JRDesignTextElement) element;
    }
    else if (widget instanceof SelectionWidget)
    {
        return getTextElement( ((SelectionWidget)widget).getRealWidget() );
    }
    return null;
}
项目:ireport-fork    文件:TextElementsToolbar.java   
private void jToggleButtonBoldItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jToggleButtonBoldItemStateChanged
    if (isInit()) return;
    boolean oldChanging = isChanging();
    setChanging(true);

    if (getSelectedTextElements().size() > 0)
    {
        boolean isFirstUndo = true;
        boolean newValue = jToggleButtonBold.isSelected();
        for (JRDesignTextElement element : getSelectedTextElements())
        {
            // TODO: add undo operation...


            if (newValue != element.isBold())
            {
                Boolean oldValue = element.isOwnBold();
                element.setBold(newValue);
                ObjectPropertyUndoableEdit opUndo = new ObjectPropertyUndoableEdit(element, "Bold",Boolean.class, oldValue , new Boolean(newValue));
                IReportManager.getInstance().addUndoableEdit(opUndo, !isFirstUndo);
                isFirstUndo = false;
            }
        }
    }

    setChanging(oldChanging);
}
项目:ireport-fork    文件:TextElementsToolbar.java   
private void modifyVerticalAlignment() {
    if (isInit()) return;
    boolean oldChanging = isChanging();
    setChanging(true);

    if (getSelectedTextElements().size() > 0)
    {
        boolean isFirstUndo = true;
        VerticalAlignEnum newValue = getSelectedVerticalAlignment();
        for (JRDesignTextElement element : getSelectedTextElements())
        {
            // if newValue is null does not do anything 
            // since the vertical alignment could be justified for which we do not
            // provide an icon...
            if (newValue != null && newValue != element.getVerticalAlignmentValue())
            {
                VerticalAlignEnum oldValue = element.getOwnVerticalAlignmentValue();
                element.setVerticalAlignment(newValue);
                ObjectPropertyUndoableEdit opUndo = new ObjectPropertyUndoableEdit(element, "VerticalAlignment",VerticalAlignEnum.class, oldValue , newValue);
                IReportManager.getInstance().addUndoableEdit(opUndo, !isFirstUndo);
                isFirstUndo = false;
            }
        }
    }

    setChanging(oldChanging);
}
项目:ireport-fork    文件:TabStopsProperty.java   
@SuppressWarnings("unchecked")
public TabStopsProperty(JRDesignTextElement element)
{
   super( JRBaseParagraph.PROPERTY_TAB_STOPS, List.class, I18n.getString("Global.Property.TabStops"),I18n.getString("Global.Property.TabStops.desc"), true,true);
   setValue("canEditAsText", Boolean.FALSE);
   setValue("useList", Boolean.TRUE);
   this.element = element;

}
项目:jasperreports    文件:JRTextElementFactory.java   
@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;
}
项目:jasperreports    文件:EditTextElementCommand.java   
public EditTextElementCommand(JRDesignTextElement textElement, EditTextElementData editTextElementData, ReportContext reportContext)
{
    this.textElement = textElement;
    this.editTextElementData = editTextElementData;
    this.reportContext = reportContext;
}
项目:PDFReporter-Studio    文件:DefaultValuesMap.java   
/**
 * Create the default property map for a wide range of object
 * @param type the type of the element for which the properties are requested
 * @return the default properties of the requested element
 */
@SuppressWarnings("deprecation")
private static HashMap<String, Object> initializeType(Object type){
    HashMap<String, Object> result = new HashMap<String, Object>();
    result.put(JRDesignStyle.PROPERTY_FONT_NAME, JRProperties.getProperty(JRFont.DEFAULT_FONT_NAME));
    result.put(JRBaseLineBox.PROPERTY_PADDING, INTEGER_ZERO);
    result.put(JRBaseLineBox.PROPERTY_TOP_PADDING, INTEGER_ZERO);
    result.put(JRBaseLineBox.PROPERTY_RIGHT_PADDING, INTEGER_ZERO);
    result.put(JRDesignStyle.PROPERTY_PDF_FONT_NAME, JRProperties.getProperty(JRFont.DEFAULT_PDF_FONT_NAME));
    result.put(JRDesignStyle.PROPERTY_PDF_ENCODING,JRProperties.getProperty(JRFont.DEFAULT_PDF_ENCODING));
    result.put(JRDesignStyle.PROPERTY_PATTERN, null);
    result.put(JRDesignStyle.PROPERTY_MARKUP,JRCommonText.MARKUP_NONE);
    result.put(JRBasePen.PROPERTY_LINE_STYLE, LineStyleEnum.SOLID);

    if (type instanceof JRStyle){

        result.put(JRDesignStyle.PROPERTY_FONT_SIZE, null);
        result.put(JRDesignStyle.PROPERTY_BOLD, null);
        result.put(JRDesignStyle.PROPERTY_ITALIC, null);
        result.put(JRDesignStyle.PROPERTY_UNDERLINE, null);
        result.put(JRDesignStyle.PROPERTY_STRIKE_THROUGH, null);
        result.put(JRDesignStyle.PROPERTY_PDF_EMBEDDED,null);
        result.put(JRDesignStyle.PROPERTY_BLANK_WHEN_NULL,null);
        result.put(JRDesignStyle.PROPERTY_VERTICAL_ALIGNMENT,null);
        result.put(JRDesignStyle.PROPERTY_HORIZONTAL_ALIGNMENT,null);
        result.put(JRDesignStyle.PROPERTY_SCALE_IMAGE,null);
        result.put(JRDesignStyle.PROPERTY_ROTATION,null);
        result.put(JRDesignStyle.PROPERTY_RADIUS,null);
        result.put(JRBasePen.PROPERTY_LINE_WIDTH, null);
        result.put(JRBasePen.PROPERTY_LINE_COLOR, null);
        result.put(JRDesignStyle.PROPERTY_BACKCOLOR, null);
        result.put(JRDesignStyle.PROPERTY_FORECOLOR, null);
        result.put(JRDesignStyle.PROPERTY_FILL, null);
        result.put(JRDesignStyle.PROPERTY_MODE, null);
    } else {
        result.put(JRDesignStyle.PROPERTY_FONT_SIZE, JRProperties.getIntegerProperty(JRFont.DEFAULT_FONT_SIZE));
        result.put(JRDesignStyle.PROPERTY_BOLD, false);
        result.put(JRDesignStyle.PROPERTY_ITALIC, false);
        result.put(JRDesignStyle.PROPERTY_UNDERLINE, false);
        result.put(JRDesignStyle.PROPERTY_STRIKE_THROUGH, false);
        result.put(JRDesignStyle.PROPERTY_PDF_EMBEDDED,JRProperties.getBooleanProperty(JRFont.DEFAULT_PDF_EMBEDDED));
        result.put(JRDesignStyle.PROPERTY_BLANK_WHEN_NULL,false);
        result.put(JRDesignStyle.PROPERTY_VERTICAL_ALIGNMENT,VerticalAlignEnum.TOP);
        result.put(JRDesignStyle.PROPERTY_HORIZONTAL_ALIGNMENT,HorizontalAlignEnum.LEFT);
        result.put(JRDesignStyle.PROPERTY_SCALE_IMAGE,ScaleImageEnum.RETAIN_SHAPE);
        result.put(JRDesignStyle.PROPERTY_ROTATION,RotationEnum.NONE);
        result.put(JRDesignStyle.PROPERTY_RADIUS,INTEGER_ZERO);
        result.put(JRBasePen.PROPERTY_LINE_WIDTH,JRPen.LINE_WIDTH_0);
        result.put(JRBasePen.PROPERTY_LINE_COLOR, Color.black);
        result.put(MGraphicElementLinePen.LINE_PEN, createBaseLinePen(type));
        result.put(MGraphicElementLineBox.LINE_BOX, createBaseLineBox(type));
        result.put(JRDesignStyle.PROPERTY_BACKCOLOR, Color.white);
        result.put(JRDesignStyle.PROPERTY_FORECOLOR, Color.black);
        result.put(JRDesignStyle.PROPERTY_FILL, FillEnum.SOLID);
        ModeEnum opaqueValue = ModeEnum.getByValue(ModeEnum.OPAQUE.getValue());
        ModeEnum transparentValue = ModeEnum.getByValue(ModeEnum.TRANSPARENT.getValue());
        if (type instanceof JRDesignTextElement){
            result.put(JRDesignStyle.PROPERTY_MODE, transparentValue);
        } else if (type instanceof JRTemplateElement){
            result.put(JRDesignStyle.PROPERTY_MODE, opaqueValue);
        } else if (type instanceof JRBaseElement) {
            result.put(JRDesignStyle.PROPERTY_MODE, opaqueValue);
        } else if (type instanceof JRBasePrintElement) {
            result.put(JRDesignStyle.PROPERTY_MODE, opaqueValue);
        } else if (type instanceof JRFillElement){
            result.put(JRDesignStyle.PROPERTY_MODE, opaqueValue);
        } else {
            result.put(JRDesignStyle.PROPERTY_MODE, transparentValue);
        }
    }
    return result;
}
项目:ireport-fork    文件:DefaultTableCellElementsLayout.java   
public void animatorFinished(AnimatorEvent arg0) {
    animations--;
    if (animations == 0)
    {
        for (Iterator iter = getNewSizes().keySet().iterator(); iter.hasNext(); )
        {
            JRDesignElement element = (JRDesignElement)iter.next();
            Rectangle rectangle = getNewSizes().get(element);
            element.setX( rectangle.x);
            element.setY( rectangle.y);
            element.setWidth( rectangle.width);
            element.setHeight( rectangle.height);

            // Calculate the best font height...
            if (element instanceof JRDesignTextElement)
            {
                JRStyledTextParser styledTextParser = JRStyledTextParser.getInstance();
                JRDesignTextElement dte = (JRDesignTextElement)element;
                dte.setFontSize(null);
                for (int i=dte.getFontSize()-1; i>1 ; --i)
                {
                        String text = "test";

                        // Convert the element in a print element...
                        Map attributes = JRFontUtil.getAttributes(new HashMap(), dte, Locale.getDefault());

                        JRStyledText styledText =
                            styledTextParser.getStyledText(
                            attributes,
                            text,
                            JRCommonText.MARKUP_STYLED_TEXT.equals(dte.getMarkup()),//FIXMEMARKUP only static styled text appears on preview. no other markup
                            Locale.getDefault()
                            );


                        JRTextMeasurer measurer = JRTextMeasurerUtil.getInstance(DefaultJasperReportsContext.getInstance()).createTextMeasurer(dte);
                        JRMeasuredText measuredText = measurer.measure(  styledText, 0, dte.getHeight(), true);

                        if  (measuredText.getTextHeight() > dte.getHeight())
                        {
                            if (i>1)
                            {
                                dte.setFontSize(i);
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                }
            }
        }
    }
}
项目:ireport-fork    文件:TextElementPropertiesFactory.java   
/**
 * Get the common properties...
 */
public static Sheet.Set getTextPropertySet(JRDesignTextElement element, JasperDesign jd)
{

    JRDesignDataset dataset = ModelUtils.getElementDataset(element, jd);
    Sheet.Set propertySet = Sheet.createPropertiesSet();
    propertySet.setName("TEXT_ELEMENT_PROPERTIES");
    propertySet.setDisplayName("Text properties");

    propertySet.put(new FontNameProperty( element ));
    propertySet.put(new FontSizeProperty( element ));

    propertySet.put(new BoldProperty( element ));
    propertySet.put(new ItalicProperty( element ));
    propertySet.put(new UnderlineProperty( element ));
    propertySet.put(new StrikeThroughProperty( element ));

    propertySet.put(new HorizontalAlignmentProperty( element ));
    propertySet.put(new VerticalAlignmentProperty( element ));
    propertySet.put(new RotationProperty( element ));
    propertySet.put(new LineSpacingProperty( element ));
    propertySet.put(new LineSpacingSizeProperty( element ));
    propertySet.put(new MarkupProperty( element ));

    propertySet.put(new FirstLineIndentProperty( element ));
    propertySet.put(new LeftIndentProperty( element ));
    propertySet.put(new RightIndentProperty( element));
    propertySet.put(new SpacingBeforeProperty( element ));
    propertySet.put(new SpacingAfterProperty( element ));

    propertySet.put(new TabStopWidthProperty( element ));
    propertySet.put(new TabStopsProperty( element ));

    propertySet.put(new PdfFontNameProperty( element ));
    propertySet.put(new PdfEmbeddedProperty( element ));
    propertySet.put(new PdfEncodingProperty( element ));

    //propertySet.put(new ReportFontProperty( element, jd ));




    //propertySet.put(new LeftProperty( element ));
    return propertySet;
}
项目:ireport-fork    文件:ElementPropertiesFactory.java   
/**
 * Convenient way to get all the properties of an element.
 * Properties positions could be reordered to have a better order.
 */
public static List<Sheet.Set> getPropertySets(JRDesignElement element, JasperDesign jd)
{
    List<Sheet.Set> sets = new ArrayList<Sheet.Set>();
    sets.add( getCommonPropertySet(element, jd) );

    if (element instanceof  JRDesignGraphicElement)
    {
        sets.addAll( GraphicElementPropertiesFactory.getGraphicPropertySets((JRDesignGraphicElement)element, jd) );
    }
    if (element instanceof  JRDesignTextElement)
    {
        sets.addAll( TextElementPropertiesFactory.getPropertySets(element, jd) );
    }
    if (element instanceof  JRDesignSubreport)
    {
        sets.addAll( SubreportPropertiesFactory.getPropertySets(element, jd) );
    }
    if (element instanceof JRDesignBreak)
    {
        sets.add( getBreakPropertySet((JRDesignBreak)element) );

    }

    if (element instanceof  JRDesignChart)
    {
        sets.addAll( ChartPropertiesFactory.getPropertySets((JRDesignChart)element, jd) );
    }



    if (element instanceof  JRBox)
    {
        sets.add( getBoxPropertySet((JRBox)element) );
    }

    if (element instanceof  JRDesignGenericElement)
    {
        sets.add(  getGenericElementPropertySet((JRDesignGenericElement)element, jd ) );
    }

    return sets;
}
项目:ireport-fork    文件:DefaultCellElementsLayout.java   
public void animatorFinished(AnimatorEvent arg0) {
        animations--;
        if (animations == 0)
        {
            for (Iterator iter = getNewSizes().keySet().iterator(); iter.hasNext(); )
            {
                JRDesignElement element = (JRDesignElement)iter.next();
                Rectangle rectangle = getNewSizes().get(element);
                element.setX( rectangle.x);
                element.setY( rectangle.y);
                element.setWidth( rectangle.width);
                element.setHeight( rectangle.height);

                // Calculate the best font height...
                if (element instanceof JRDesignTextElement)
                {
                    JRStyledTextParser styledTextParser = JRStyledTextParser.getInstance();
                    JRDesignTextElement dte = (JRDesignTextElement)element;
                    dte.setFontSize(null);
                    for (int i=dte.getFontSize()-1; i>1 ; --i)
                    {
                            String text = "test";

                            // Convert the element in a print element...
                            Map<Attribute, Object> attributes = JRFontUtil.getAttributes(new HashMap(), dte, Locale.getDefault());

                            JRStyledText styledText = 
                                styledTextParser.getStyledText(
                                attributes, 
                                text, 
                                JRCommonText.MARKUP_STYLED_TEXT.equals(dte.getMarkup()),//FIXMEMARKUP only static styled text appears on preview. no other markup
                                Locale.getDefault()
);

                            JasperReportsContext context = IRLocalJasperReportsContext.getInstance();

                            JRTextMeasurerUtil measurerUtil = JRTextMeasurerUtil.getInstance(context);
                            JRTextMeasurer measurer = measurerUtil.createTextMeasurer(dte);
                            JRMeasuredText measuredText = measurer.measure(  styledText, 0, dte.getHeight(), true);

                            if  (measuredText.getTextHeight() > dte.getHeight())
                            {
                                if (i>1)
                                {
                                    dte.setFontSize(i);
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }
                    }
                }
            }
        }
    }