@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); }
public void widgetSelected(SelectionEvent e) { if (!refreshing){ List<Object> selection = getSelectionForType(MTextElement.class); if (selection.isEmpty()) return; JSSCompoundCommand changeSizeCommands = new JSSCompoundCommand(null); String property = ""; Object data = e.widget.getData(); if (data instanceof VerticalAlignEnum) property = JRBaseStyle.PROPERTY_VERTICAL_ALIGNMENT; else if (data instanceof HorizontalAlignEnum) property = JRBaseStyle.PROPERTY_HORIZONTAL_ALIGNMENT; else return; for (Object textElement : selection){ changeSizeCommands.setReferenceNodeIfNull(textElement); Command c = createCommand(textElement, data, property); if (c != null) { changeSizeCommands.add(c); } } CommandStack cs = getCommandStack(); cs.execute(changeSizeCommands); } }
/** * */ public JRPrintElement convert(final ReportConverter reportConverter, final JRComponentElement element) { MapComponent map = (MapComponent) element.getComponent(); JRBasePrintImage printImage = new JRBasePrintImage(element.getDefaultStyleProvider()); Renderable cacheRenderer = getRenderable(reportConverter, element, map, printImage); printImage.setUUID(element.getUUID()); printImage.setX(element.getX()); printImage.setY(element.getY()); printImage.setWidth(element.getWidth()); printImage.setHeight(element.getHeight()); printImage.setStyle(element.getStyle()); printImage.setMode(element.getModeValue()); printImage.setBackcolor(element.getBackcolor()); printImage.setForecolor(element.getForecolor()); printImage.setLazy(false); // FIXMEMAP there are no scale image, alignment and onError attributes // defined for the map element printImage.setScaleImage(ScaleImageEnum.CLIP); printImage.setHorizontalAlignment(HorizontalAlignEnum.LEFT); printImage.setVerticalAlignment(VerticalAlignEnum.TOP); printImage.setRenderable(cacheRenderer); return printImage; }
private JRDesignStaticText createLabel(JasperDesign jd, String text, int w, int h, String styleName) { JRDesignStaticText element = new JRDesignStaticText(); element.setX(0); element.setY(0); element.setWidth(w); element.setHeight(h); element.setText(text); element.setHorizontalAlignment( HorizontalAlignEnum.CENTER ); element.setVerticalAlignment( VerticalAlignEnum.MIDDLE); if (styleName != null && jd.getStylesMap().containsKey(styleName)) { element.setStyle( (JRStyle) jd.getStylesMap().get(styleName) ); } return element; }
private static JRDesignTextField createTextField(ODLTableDefinition table, int columnIndex) { JRDesignTextField textField = new JRDesignTextField(); textField.setVerticalAlignment(VerticalAlignEnum.MIDDLE); JRDesignExpression expression = new JRDesignExpression(); String fld = "$F{" + table.getColumnName(columnIndex) + "}"; if (table.getColumnType(columnIndex) == ODLColumnType.DOUBLE) { String combined = fld + "!=null ? new DecimalFormat(\"###,###.###\").format(" + fld + "):\"\""; expression.setText(combined); } else { expression.setText(fld); } textField.setExpression(expression); textField.setPrintWhenDetailOverflows(false); return textField; }
@Override public void test() { super.test(); numberOfPagesTest(1); columnDetailStyleTest(column1, 0, null, null, "Arial", 10f, true, null); columnDetailBorderTest(column1, 0, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1); columnDetailBorderTest(column2, 0, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1); columnDetailBorderTest(column3, 0, null, LineStyleEnum.SOLID, 2, null, LineStyleEnum.SOLID, 2, null, LineStyleEnum.SOLID, 2, null, LineStyleEnum.SOLID, 2); columnDetailStyleTest(column4, 0, null, null, "Arial", 10f, true, null); columnDetailBorderTest(column4, 0, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1); columnDetailAlignmentTest(column1, 0, HorizontalAlignEnum.CENTER); columnDetailAlignmentTest(column2, 0, HorizontalAlignEnum.LEFT); columnDetailAlignmentTest(column3, 0, HorizontalAlignEnum.CENTER); columnDetailAlignmentTest(column1, 0, VerticalAlignEnum.TOP); columnDetailAlignmentTest(column2, 0, VerticalAlignEnum.TOP); columnDetailAlignmentTest(column3, 0, VerticalAlignEnum.MIDDLE); }
@Override public void setPropertyValue(Object id, Object value) { JRDesignComponentElement jrElement = (JRDesignComponentElement) getValue(); HtmlComponent htmlComp = (HtmlComponent) jrElement.getComponent(); if (id.equals(HtmlComponent.PROPERTY_EVALUATION_TIME)) htmlComp.setEvaluationTime((EvaluationTimeEnum) evaluationTimeD .getEnumValue(value)); else if (id.equals(HtmlComponent.PROPERTY_EVALUATION_GROUP)) htmlComp.setEvaluationGroup((String) value); else if (id.equals(HtmlComponent.PROPERTY_SCALE_TYPE)) htmlComp.setScaleType((ScaleImageEnum) scaleTypeD .getEnumValue(value)); else if (id.equals(HtmlComponent.PROPERTY_HORIZONTAL_ALIGN)) htmlComp.setHorizontalAlign((HorizontalAlignEnum) hAlignD .getEnumValue(value)); else if (id.equals(HtmlComponent.PROPERTY_VERTICAL_ALIGN)) htmlComp.setVerticalAlign((VerticalAlignEnum) vAlignD .getEnumValue(value)); else if (id.equals(HtmlComponent.PROPERTY_HTMLCONTENT_EXPRESSION)) htmlComp.setHtmlContentExpression(ExprUtil.setValues( htmlComp.getHtmlContentExpression(), value)); else if (id.equals(HtmlComponent.PROPERTY_CLIP_ON_OVERFLOW)) htmlComp.setClipOnOverflow((Boolean) value); else super.setPropertyValue(id, value); }
@Override public void setPropertyValue(Object id, Object value) { JRDesignComponentElement jrElement = (JRDesignComponentElement) getValue(); SortComponent component = (SortComponent) jrElement.getComponent(); if (id.equals(SortComponent.PROPERTY_HANDLER_COLOR)) component.setHandlerColor(Colors.getAWT4SWTRGBColor((AlfaRGB) value)); else if (id.equals(SortComponent.PROPERTY_COLUMN_NAME)) component.setSortFieldName((String) value); else if (id.equals(SortComponent.PROPERTY_COLUMN_TYPE)) component.setSortFieldType((SortFieldTypeEnum) EnumHelper .getSetValue(SortFieldTypeEnum.values(), value, 0, false)); else if (id.equals(SortComponent.PROPERTY_EVALUATION_TIME)) component.setEvaluationTime((EvaluationTimeEnum) EnumHelper .getSetValue(EvaluationTimeEnum.values(), value, 1, false)); else if (id.equals(SortComponent.PROPERTY_EVALUATION_GROUP)) { component.setEvaluationGroup((String) value); } else if (id.equals(SortComponent.PROPERTY_HANDLER_HORIZONTAL_ALIGN)) { component .setHandlerHorizontalAlign((HorizontalAlignEnum) EnumHelper .getSetValue(HorizontalAlignEnum.values(), value, 1, false)); } else if (id.equals(SortComponent.PROPERTY_HANDLER_VERTICAL_ALIGN)) { component.setHandlerVerticalAlign((VerticalAlignEnum) EnumHelper .getSetValue(VerticalAlignEnum.values(), value, 1, false)); } else super.setPropertyValue(id, value); }
private TextStyle createDefaultElement(){ TextStyle defaultTextStyle = new TextStyle(); defaultTextStyle.setBackGround(AlfaRGB.getFullyOpaque(new RGB(255,255,255))); defaultTextStyle.setForeGround(AlfaRGB.getFullyOpaque(new RGB(0,0,0))); defaultTextStyle.setHorizontalAlignmen(HorizontalAlignEnum.LEFT); defaultTextStyle.setVerticalAlignmen(VerticalAlignEnum.TOP); defaultTextStyle.setTransparent(true); defaultTextStyle.setRotation(RotationEnum.NONE); JRBaseFont font = new JRBaseFont(); font.setFontName("Arial"); //$NON-NLS-1$ font.setFontSize(8f); font.setBold(false); font.setItalic(false); font.setUnderline(false); font.setStrikeThrough(false); defaultTextStyle.setFont(font); JRBaseLineBox box = new JRBaseLineBox(null); box.setPadding(null); box.setTopPadding(0); box.setBottomPadding(0); box.setLeftPadding(0); box.setRightPadding(0); defaultTextStyle.setBorders(box); defaultTextStyle.setDescription(Messages.TextStyleView_sampleText); return defaultTextStyle; }
public TextStyle(JRStyle style){ super(null,null); setTransparent(style.getOwnModeValue() != null ? ModeEnum.TRANSPARENT.equals(style.getOwnModeValue()) : true); setBackGround(style.getOwnBackcolor()); setForeGround(style.getOwnForecolor()); setVerticalAlignmen(style.getOwnVerticalAlignmentValue() != null ? style.getOwnVerticalAlignmentValue() : VerticalAlignEnum.TOP); setHorizontalAlignmen(style.getOwnHorizontalAlignmentValue() != null ? style.getOwnHorizontalAlignmentValue() : HorizontalAlignEnum.LEFT); setRotation(style.getOwnRotationValue() != null ? style.getOwnRotationValue() : RotationEnum.NONE); JRFont font = new JRBaseFont(); font.setBold(style.isOwnBold() != null ? style.isOwnBold() : false); font.setItalic(new Boolean(style.isOwnItalic() != null ? style.isOwnItalic() : false)); style.isItalic(); font.setUnderline(new Boolean(style.isOwnUnderline() != null ? style.isOwnUnderline() : false)); font.setStrikeThrough(new Boolean(style.isOwnStrikeThrough() != null ? style.isOwnStrikeThrough() : false)); font.setFontName(new String(style.getOwnFontName())); font.setFontSize(new Float(style.getOwnFontsize())); setFont(font); JRLineBox originBox = style.getLineBox(); JRBaseLineBox copyBox = new JRBaseLineBox(null); copyBox.setPadding(originBox.getOwnPadding() != null ? new Integer(originBox.getOwnPadding()): null); copyBox.setTopPadding(originBox.getOwnTopPadding() != null ? new Integer(originBox.getOwnTopPadding()): null); copyBox.setBottomPadding(originBox.getOwnBottomPadding() != null ? new Integer(originBox.getOwnBottomPadding()): null); copyBox.setLeftPadding(originBox.getOwnLeftPadding() != null ? new Integer(originBox.getOwnLeftPadding()): null); copyBox.setRightPadding(originBox.getOwnRightPadding() != null ? new Integer(originBox.getOwnRightPadding()): null); copyLinePen(originBox.getPen(), copyBox.getPen()); copyLinePen(originBox.getLeftPen(), copyBox.getLeftPen()); copyLinePen(originBox.getRightPen(), copyBox.getRightPen()); copyLinePen(originBox.getBottomPen(), copyBox.getBottomPen()); copyLinePen(originBox.getTopPen(), copyBox.getTopPen()); setBorders(copyBox); String name = style.getName(); if (name != null && !name.isEmpty()) setDescription(name); }
@Override public List getTagList() { List tags = new java.util.ArrayList(); tags.add(new Tag(VerticalAlignEnum.TOP, I18n.getString("Global.Property.Top"))); tags.add(new Tag(VerticalAlignEnum.MIDDLE, I18n.getString("Global.Property.Middle"))); tags.add(new Tag(VerticalAlignEnum.BOTTOM, I18n.getString("Global.Property.Bottom"))); return tags; }
private JRDesignStaticText createLabel(String text, int w, int h) { JRDesignStaticText element = new JRDesignStaticText(); element.setX(0); element.setY(0); element.setWidth(w); element.setHeight(h); element.setText(text); element.setHorizontalAlignment( HorizontalAlignEnum.CENTER ); element.setVerticalAlignment( VerticalAlignEnum.MIDDLE); return element; }
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); }
private VerticalAlignEnum getSelectedVerticalAlignment() { if (jToggleButtonAlignTop.isSelected()) return VerticalAlignEnum.TOP; if (jToggleButtonAlignMiddle.isSelected()) return VerticalAlignEnum.MIDDLE; if (jToggleButtonAlignBottom.isSelected()) return VerticalAlignEnum.BOTTOM; return null; }
private boolean setVerticalAlignment(boolean firstElement, VerticalAlignEnum verticalAlignment) { if (!firstElement) { VerticalAlignEnum selectedValue = getSelectedVerticalAlignment(); if (selectedValue != null && selectedValue != verticalAlignment) { setSelectedVerticalAlignment(null); } } setSelectedVerticalAlignment(verticalAlignment); return true; }
@SuppressWarnings(value = "unchecked") public VerticalAlignmentProperty(JRBaseStyle style) { super(VerticalAlignEnum.class, style); this.style = style; setValue("suppressCustomEditor", Boolean.TRUE); }
@Override public List getTagList() { List tags = new java.util.ArrayList(); tags.add(new Tag(VerticalAlignEnum.TOP, I18n.getString("Global.Property.Top"))); tags.add(new Tag(VerticalAlignEnum.MIDDLE, I18n.getString("Global.Property.Middle"))); tags.add(new Tag(VerticalAlignEnum.BOTTOM, I18n.getString("Global.Property.Bottom"))); //tags.add(new Tag(new Byte(JRAlignment.VERTICAL_ALIGN_JUSTIFIED), I18n.getString("Global.Property.Justified"))); return tags; }
/** * add user friendly paramters to the band and report port parameters if not * already present * * @param designFile * @param targetBand * @param maxY * @return * @throws JRException */ private int addParametersToDisplayReportParameters(JasperDesign designFile, JRDesignBand targetBand, int maxY) throws JRException { for (ReportParameter<?> param : reportProperties.getFilterBuilder().getReportParameters()) { if (param.displayInreport()) { for (String parameterName : param.getParameterNames()) { JRDesignStaticText labelElement = new JRDesignStaticText(); String strippedLabel = param.getLabel(parameterName).replaceAll("ReportParameter", ""); labelElement.setText(strippedLabel); labelElement.setWidth(125); labelElement.setHeight(20); labelElement.setBackcolor(new Color(208, 208, 208)); labelElement.setMode(ModeEnum.OPAQUE); labelElement.setVerticalAlignment(VerticalAlignEnum.MIDDLE); labelElement.setX(0); labelElement.setY(maxY); labelElement.setFontName("SansSerif"); labelElement.setFontSize(12); targetBand.addElement(labelElement); JRDesignTextField valueElement = new JRDesignTextField(); valueElement.setExpression(new JRDesignExpression("$P{ParamDisplay-" + parameterName + "}")); valueElement.setWidth(400); valueElement.setHeight(20); valueElement.setBackcolor(new Color(208, 208, 208)); valueElement.setMode(ModeEnum.OPAQUE); valueElement.setX(125); valueElement.setY(maxY); valueElement.setFontName("SansSerif"); valueElement.setFontSize(12); valueElement.setVerticalAlignment(VerticalAlignEnum.MIDDLE); targetBand.addElement(valueElement); maxY = valueElement.getY() + valueElement.getHeight(); if (!designFile.getParametersMap().containsKey("ParamDisplay-" + parameterName)) { JRDesignParameter parameter = new JRDesignParameter(); parameter.setName("ParamDisplay-" + parameterName); parameter.setValueClass(String.class); parameter.setForPrompting(false); designFile.addParameter(parameter); } } } } return maxY; }
protected void verticalAlignmentTest(String name, int index, VerticalAlignEnum verticalAlignment) { JRAlignment element = (JRAlignment) getElementAt(name, index); if (verticalAlignment == null) { Assert.assertEquals("verticalAlignment", VerticalAlignEnum.TOP, element.getVerticalAlignmentValue()); } Assert.assertEquals("verticalAlignment", verticalAlignment, element.getVerticalAlignmentValue()); }
public static JRPrintImage getImage( JasperReportsContext jasperReportsContext, JRGenericPrintElement element) throws JRException, IOException { JRBasePrintImage printImage = new JRBasePrintImage( element.getDefaultStyleProvider()); printImage.setUUID(element.getUUID()); printImage.setX(element.getX()); printImage.setY(element.getY()); printImage.setWidth(element.getWidth()); printImage.setHeight(element.getHeight()); printImage.setStyle(element.getStyle()); printImage.setMode(element.getModeValue()); printImage.setBackcolor(element.getBackcolor()); printImage.setForecolor(element.getForecolor()); printImage.setLazy(false); printImage.setScaleImage(ScaleImageEnum.CLIP); printImage.setHorizontalAlignment(HorizontalAlignEnum.LEFT); printImage.setVerticalAlignment(VerticalAlignEnum.TOP); Renderable cacheRenderer = (Renderable) element .getParameterValue(WmsMapPrintElement.PARAMETER_CACHE_RENDERER); if (cacheRenderer == null) { cacheRenderer = getImageRenderable(jasperReportsContext, element); element.setParameterValue(WmsMapPrintElement.PARAMETER_CACHE_RENDERER, cacheRenderer); } printImage.setRenderable(cacheRenderer); return printImage; }
/** * Creates the property descriptors. * * @param desc * the desc */ public void createPropertyDescriptors(List<IPropertyDescriptor> desc, Map<String, Object> defaultsMap) { super.createPropertyDescriptors(desc, defaultsMap); JRExpressionPropertyDescriptor contentExprD = new JRExpressionPropertyDescriptor( HtmlComponent.PROPERTY_HTMLCONTENT_EXPRESSION, Messages.MHtml_content_expression); contentExprD .setDescription(Messages.MHtml_content_expression_description); desc.add(contentExprD); scaleTypeD = new JSSEnumPropertyDescriptor( HtmlComponent.PROPERTY_SCALE_TYPE, Messages.MHtml_scaletype, ScaleImageEnum.class, NullEnum.NOTNULL); scaleTypeD.setDescription(Messages.MHtml_scaletype_description); desc.add(scaleTypeD); CheckBoxPropertyDescriptor clipOverflow = new CheckBoxPropertyDescriptor( HtmlComponent.PROPERTY_CLIP_ON_OVERFLOW, Messages.MHtml_cliponoverflow, NullEnum.NULL); clipOverflow.setDescription(Messages.MHtml_cliponoverflow_desc); desc.add(clipOverflow); hAlignD = new JSSEnumPropertyDescriptor( HtmlComponent.PROPERTY_HORIZONTAL_ALIGN, Messages.MHtml_horizontalalign, HorizontalAlignEnum.class, NullEnum.NOTNULL, 3); hAlignD.setDescription(Messages.MHtml_horizontalalign_description); desc.add(hAlignD); vAlignD = new JSSEnumPropertyDescriptor( HtmlComponent.PROPERTY_VERTICAL_ALIGN, Messages.MHtml_verticalalign, VerticalAlignEnum.class, NullEnum.NOTNULL, 3); vAlignD.setDescription(Messages.MHtml_verticalalign_description); desc.add(vAlignD); evaluationTimeD = new JSSEnumPropertyDescriptor( HtmlComponent.PROPERTY_EVALUATION_TIME, Messages.MHtml_evaluation_time, EvaluationTimeEnum.class, NullEnum.NOTNULL); evaluationTimeD .setDescription(Messages.MHtml_evaluation_time_description); desc.add(evaluationTimeD); evaluationGroupNameD = new RComboBoxPropertyDescriptor( HtmlComponent.PROPERTY_EVALUATION_GROUP, Messages.MHtml_evaluation_group, new String[] { "" }); //$NON-NLS-1$ evaluationGroupNameD .setDescription(Messages.MHtml_evaluation_group_description); desc.add(evaluationGroupNameD); contentExprD.setCategory(Messages.common_properties_category); scaleTypeD.setCategory(Messages.common_properties_category); hAlignD.setCategory(Messages.common_properties_category); vAlignD.setCategory(Messages.common_properties_category); evaluationTimeD.setCategory(Messages.common_properties_category); evaluationGroupNameD.setCategory(Messages.common_properties_category); clipOverflow.setCategory(Messages.common_properties_category); defaultsMap.put(HtmlComponent.PROPERTY_EVALUATION_TIME, evaluationTimeD.getEnumValue(EvaluationTimeEnum.NOW)); defaultsMap.put(HtmlComponent.PROPERTY_SCALE_TYPE, scaleTypeD.getEnumValue(ScaleImageEnum.RETAIN_SHAPE)); defaultsMap.put(HtmlComponent.PROPERTY_HORIZONTAL_ALIGN, hAlignD.getEnumValue(HorizontalAlignEnum.LEFT)); defaultsMap.put(HtmlComponent.PROPERTY_VERTICAL_ALIGN, vAlignD.getEnumValue(VerticalAlignEnum.MIDDLE)); defaultsMap.put(HtmlComponent.PROPERTY_CLIP_ON_OVERFLOW, Boolean.FALSE); }
/** * Creates the property descriptors. * * @param desc * the desc */ @Override public void createPropertyDescriptors(List<IPropertyDescriptor> desc, Map<String, Object> defaultsMap) { super.createPropertyDescriptors(desc, defaultsMap); ComboBoxPropertyDescriptor evaluationTimeD = new ComboBoxPropertyDescriptor( SortComponent.PROPERTY_EVALUATION_TIME, Messages.common_evaluation_time, EnumHelper.getEnumNames( EvaluationTimeEnum.values(), NullEnum.NOTNULL)); evaluationTimeD .setDescription(Messages.MGenericElement_evaluation_time_description); desc.add(evaluationTimeD); evaluationGroupNameD = new RComboBoxPropertyDescriptor( SortComponent.PROPERTY_EVALUATION_GROUP, Messages.MGenericElement_evaluation_group_name, new String[] { "" }); //$NON-NLS-2$ evaluationGroupNameD .setDescription(Messages.MGenericElement_evaluation_group_name_description); desc.add(evaluationGroupNameD); ColorPropertyDescriptor color = new ColorPropertyDescriptor( SortComponent.PROPERTY_HANDLER_COLOR, "Handler Color", NullEnum.NULL); color.setDescription("Handler color"); desc.add(color); ComboBoxPropertyDescriptor horizAlign = new ComboBoxPropertyDescriptor( SortComponent.PROPERTY_HANDLER_HORIZONTAL_ALIGN, "Handler Horizontal Alignement", EnumHelper.getEnumNames( HorizontalAlignEnum.values(), NullEnum.NOTNULL)); horizAlign.setDescription("Handler horizontal alignement"); desc.add(horizAlign); ComboBoxPropertyDescriptor vertAlign = new ComboBoxPropertyDescriptor( SortComponent.PROPERTY_HANDLER_VERTICAL_ALIGN, "Handler Vertical Alignement", EnumHelper.getEnumNames( VerticalAlignEnum.values(), NullEnum.NOTNULL)); vertAlign.setDescription("Handler vertical alignement"); desc.add(vertAlign); ComboBoxPropertyDescriptor sortFieldType = new ComboBoxPropertyDescriptor( SortComponent.PROPERTY_COLUMN_TYPE, "SortField Type", EnumHelper.getEnumNames(SortFieldTypeEnum.values(), NullEnum.NOTNULL)); sortFieldType.setDescription("SortField type"); desc.add(sortFieldType); NTextPropertyDescriptor sortFieldName = new NTextPropertyDescriptor( SortComponent.PROPERTY_COLUMN_NAME, "SortField Name"); sortFieldName.setDescription("SortField name"); desc.add(sortFieldName); color.setCategory("Sort Properties"); sortFieldType.setCategory("Sort Properties"); sortFieldName.setCategory("Sort Properties"); horizAlign.setCategory("Sort Properties"); vertAlign.setCategory("Sort Properties"); evaluationTimeD.setCategory("Sort Properties"); evaluationGroupNameD.setCategory("Sort Properties"); defaultsMap.put(SortComponent.PROPERTY_HANDLER_VERTICAL_ALIGN, VerticalAlignEnum.MIDDLE); defaultsMap.put(SortComponent.PROPERTY_HANDLER_HORIZONTAL_ALIGN, HorizontalAlignEnum.LEFT); defaultsMap.put(SortComponent.PROPERTY_EVALUATION_TIME, EvaluationTimeEnum.NOW); defaultsMap.put(SortComponent.PROPERTY_HANDLER_COLOR, null); defaultsMap.put(SortComponent.PROPERTY_COLUMN_TYPE, SortFieldTypeEnum.FIELD); }
/** * 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; }
@Override public void createPropertyDescriptors(List<IPropertyDescriptor> desc, Map<String, Object> defaultsMap) { super.createPropertyDescriptors(desc, defaultsMap); RWComboBoxPropertyDescriptor markupD = new RWComboBoxPropertyDescriptor(JRBaseStyle.PROPERTY_MARKUP, Messages.MTextElement_markup, ModelUtils.getMarkups(getJasperConfiguration()), NullEnum.INHERITED); markupD.setDescription(Messages.MTextElement_markup_description); desc.add(markupD); hAlignD = new HAlignPropertyDescriptor(JRBaseStyle.PROPERTY_HORIZONTAL_ALIGNMENT, Messages.common_horizontal_alignment, HorizontalAlignEnum.class, NullEnum.INHERITED); hAlignD.setDescription(Messages.MTextElement_horizontal_alignment_description); desc.add(hAlignD); vAlignD = new VAlignPropertyDescriptor(JRBaseStyle.PROPERTY_VERTICAL_ALIGNMENT, Messages.common_vertical_alignment, VerticalAlignEnum.class, NullEnum.INHERITED); vAlignD.setDescription(Messages.MTextElement_vertical_alignment_description); desc.add(vAlignD); rotationD = new RotationPropertyDescriptor(JRBaseStyle.PROPERTY_ROTATION, Messages.common_rotation, RotationEnum.class, NullEnum.INHERITED); rotationD.setDescription(Messages.MTextElement_rotation_description); desc.add(rotationD); JRPropertyDescriptor paragraph = new JRPropertyDescriptor(PARAGRAPH, "Paragraph"); desc.add(paragraph); setHelpPrefix(desc, "net.sf.jasperreports.doc/docs/schema.reference.html?cp=0_1#textElement"); tFont = getMFont(); tFont.createPropertyDescriptors(desc, defaultsMap); paragraph.setCategory(Messages.MTextElement_text_properties_category); markupD.setCategory(Messages.MTextElement_text_properties_category); hAlignD.setCategory(Messages.MTextElement_text_properties_category); vAlignD.setCategory(Messages.MTextElement_text_properties_category); rotationD.setCategory(Messages.MTextElement_text_properties_category); defaultsMap.put(JRBaseStyle.PROPERTY_HORIZONTAL_ALIGNMENT, null); defaultsMap.put(JRBaseStyle.PROPERTY_VERTICAL_ALIGNMENT, null); defaultsMap.put(JRBaseStyle.PROPERTY_ROTATION, null); }
@Override public void setPropertyValue(Object id, Object value) { JRDesignImage jrElement = (JRDesignImage) getValue(); if (id.equals(JRBaseStyle.PROPERTY_FILL)) jrElement.setFill((FillEnum) fillD.getEnumValue(value)); else if (id.equals(JRBaseStyle.PROPERTY_SCALE_IMAGE)) jrElement.setScaleImage((ScaleImageEnum) scaleImageD.getEnumValue(value)); else if (id.equals(JRBaseStyle.PROPERTY_HORIZONTAL_ALIGNMENT)) jrElement.setHorizontalAlignment((HorizontalAlignEnum) hAlignD.getEnumValue(value)); else if (id.equals(JRBaseStyle.PROPERTY_VERTICAL_ALIGNMENT)) jrElement.setVerticalAlignment((VerticalAlignEnum) vAlignD.getEnumValue(value)); else if (id.equals(JRBaseImage.PROPERTY_ON_ERROR_TYPE)) jrElement.setOnErrorType((OnErrorTypeEnum) onErrorTypeD.getEnumValue(value)); else if (id.equals(JRDesignImage.PROPERTY_EVALUATION_TIME)) jrElement.setEvaluationTime((EvaluationTimeEnum) evaluationTimeD.getEnumValue(value)); else if (id.equals(JRDesignImage.PROPERTY_EVALUATION_GROUP)) { if (value != null && !value.equals("")) { //$NON-NLS-1$ JRDesignDataset dataset = (JRDesignDataset)getElementDataset(); JRGroup group = (JRGroup) dataset.getGroupsMap().get(value); jrElement.setEvaluationGroup(group); } } else if (id.equals(JRDesignImage.PROPERTY_EXPRESSION)) jrElement.setExpression(ExprUtil.setValues(jrElement.getExpression(), value)); else if (id.equals(JRBaseImage.PROPERTY_USING_CACHE)) jrElement.setUsingCache((Boolean) value); else if (id.equals(JRBaseImage.PROPERTY_LAZY)) jrElement.setLazy(((Boolean) value).booleanValue()); else if (id.equals(JRDesignHyperlink.PROPERTY_LINK_TARGET)) jrElement.setLinkTarget((String) value); else if (id.equals(JRDesignHyperlink.PROPERTY_LINK_TYPE)) jrElement.setLinkType((String) value); else if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_ANCHOR_EXPRESSION)) jrElement.setHyperlinkAnchorExpression(ExprUtil.setValues(jrElement.getHyperlinkAnchorExpression(), value)); else if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_PAGE_EXPRESSION)) jrElement.setHyperlinkPageExpression(ExprUtil.setValues(jrElement.getHyperlinkPageExpression(), value)); else if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_REFERENCE_EXPRESSION)) jrElement.setHyperlinkReferenceExpression(ExprUtil.setValues(jrElement.getHyperlinkReferenceExpression(), value)); else if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_TOOLTIP_EXPRESSION)) jrElement.setHyperlinkTooltipExpression(ExprUtil.setValues(jrElement.getHyperlinkTooltipExpression(), value)); else if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_WHEN_EXPRESSION)) { jrElement.setHyperlinkWhenExpression(ExprUtil.setValues(jrElement.getHyperlinkWhenExpression(), value)); } else if (id.equals(JRDesignImage.PROPERTY_ANCHOR_NAME_EXPRESSION)) jrElement.setAnchorNameExpression(ExprUtil.setValues(jrElement.getAnchorNameExpression(), value)); else if (id.equals(JRDesignImage.PROPERTY_BOOKMARK_LEVEL)) jrElement.setBookmarkLevel(value != null ? Integer.parseInt(value.toString()) : 0); else if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_PARAMETERS)) { if (value instanceof ParameterDTO) { ParameterDTO v = (ParameterDTO) value; JRHyperlinkParameter[] hyperlinkParameters = jrElement.getHyperlinkParameters(); if (hyperlinkParameters != null) for (JRHyperlinkParameter prm : hyperlinkParameters) jrElement.removeHyperlinkParameter(prm); for (JRHyperlinkParameter param : v.getValue()) jrElement.addHyperlinkParameter(param); propertyDTO = v; } } super.setPropertyValue(id, value); }
private VerticalAlignEnum getVerticalAlignment(){ if (middleVAlignment.getSelection()) return VerticalAlignEnum.MIDDLE; else if (bottomVAlignment.getSelection()) return VerticalAlignEnum.BOTTOM; else return VerticalAlignEnum.TOP; }
private void setVerticalAlignment(){ VerticalAlignEnum align = element.getVerticalAlignmen(); if (VerticalAlignEnum.MIDDLE.equals(align)) middleVAlignment.setSelection(true); else if (VerticalAlignEnum.BOTTOM.equals(align)) bottomVAlignment.setSelection(true); else topVAlignment.setSelection(true); }
public VerticalAlignEnum getVerticalAlignmen(){ return (VerticalAlignEnum)getProperty(VERTICAL_ALIGNMENT); }
public void setVerticalAlignmen(VerticalAlignEnum value){ storePropertiy(VERTICAL_ALIGNMENT, value); }
/** * Rebuild a CrosstabStyle from its XML representation * * @param xmlNode an XML node with the representation of a CrosstabStyle * @return the CrosstabStyle builded from the xmlNode, or null if something goes wrong during the rebuilding */ @Override public TemplateStyle buildFromXML(Node xmlNode) { try{ NamedNodeMap rootAttributes = xmlNode.getAttributes(); VerticalAlignEnum verticalAlignment = VerticalAlignEnum.getByValue(Byte.valueOf(rootAttributes.getNamedItem("verticalAlignment").getNodeValue())); HorizontalAlignEnum horizontalAlignment = HorizontalAlignEnum.getByValue(Byte.valueOf(rootAttributes.getNamedItem("horizontalAlignment").getNodeValue())); RotationEnum rotation = RotationEnum.getByValue(Byte.valueOf(rootAttributes.getNamedItem("rotation").getNodeValue())); boolean transparent = rootAttributes.getNamedItem("isTransparent").getNodeValue().equals("true"); AlfaRGB background = null; AlfaRGB foreground = null; JRFont font = null; JRLineBox box = null; Node firstChild = xmlNode.getFirstChild(); String description = null; while(firstChild!=null){ if (firstChild.getNodeName().equals("foreground")){ foreground = rgbColor(firstChild); } else if (firstChild.getNodeName().equals("background")) { background = rgbColor(firstChild); } else if (firstChild.getNodeName().equals("font")) { font = buildFont(firstChild); } else if (firstChild.getNodeName().equals("linebox")) { box = buildBox(firstChild); } else if (firstChild.getNodeName().equals("description")) { Node descriptionNode = firstChild.getChildNodes().item(0); description = descriptionNode != null ? descriptionNode.getNodeValue() : ""; } firstChild = firstChild.getNextSibling(); } TextStyle result = new TextStyle(); result.setVerticalAlignmen(verticalAlignment); result.setHorizontalAlignmen(horizontalAlignment); result.setRotation(rotation); result.setTransparent(transparent); result.setBackGround(background); result.setForeGround(foreground); result.setFont(font); result.setBorders(box); result.setDescription(description); return result; } catch(Exception ex){ System.out.println("Unable to rebuild the text style"); ex.printStackTrace(); return null; } }
@SuppressWarnings("unchecked") public HandlerVerticalAlignmentProperty(SortComponent component) { super(VerticalAlignEnum.class, component); this.component = component; }
@Override public void setPropertyValue(Object alignment) { component.setHandlerVerticalAlign((VerticalAlignEnum)alignment); }
@SuppressWarnings("unchecked") public VerticalAlignmentProperty(HtmlComponent component) { super(VerticalAlignEnum.class, component); this.component = component; }
@Override public void setPropertyValue(Object alignment) { component.setVerticalAlign((VerticalAlignEnum)alignment); }
private void setSelectedVerticalAlignment(VerticalAlignEnum b) { jToggleButtonAlignTop.setSelected(b != null && b == VerticalAlignEnum.TOP); jToggleButtonAlignMiddle.setSelected(b != null && b == VerticalAlignEnum.MIDDLE); jToggleButtonAlignBottom.setSelected(b != null && b == VerticalAlignEnum.BOTTOM); }
@Override public void setPropertyValue(Object newValue) { style.setVerticalAlignment((VerticalAlignEnum)newValue); }
@SuppressWarnings("unchecked") public VerticalAlignmentProperty(JRAlignment element) { super(VerticalAlignEnum.class, element); this.element = element; }
@Override public void setPropertyValue(Object alignment) { element.setVerticalAlignment((VerticalAlignEnum)alignment); }