public JRPrintText getTextElementReplacement( JRExporterContext exporterContext, JRGenericPrintElement element ) { JRBasePrintText text = new JRBasePrintText(exporterContext.getExportedReport().getDefaultStyleProvider()); text.setX(element.getX()); text.setY(element.getY()); text.setWidth(element.getWidth()); text.setHeight(element.getHeight()); text.setText("[Open Flash Chart Component]"); text.setMode(ModeEnum.OPAQUE); text.setBackcolor(Color.lightGray); text.setHorizontalTextAlign(HorizontalTextAlignEnum.CENTER); text.setVerticalTextAlign(VerticalTextAlignEnum.MIDDLE); text.getLineBox().getPen().setLineWidth(1f); text.getLineBox().getPen().setLineColor(Color.black); text.getLineBox().getPen().setLineStyle(LineStyleEnum.DASHED); JRTextMeasurerUtil.getInstance(exporterContext.getJasperReportsContext()).measureTextElement(text); return text; }
protected static void setPenAttributes(Attributes atts, JRPen pen) { String lineWidth = atts.getValue(JRXmlConstants.ATTRIBUTE_lineWidth); if (lineWidth != null && lineWidth.length() > 0) { pen.setLineWidth(Float.parseFloat(lineWidth)); } LineStyleEnum lineStyle = LineStyleEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_lineStyle)); if (lineStyle != null) { pen.setLineStyle(lineStyle); } String lineColor = atts.getValue(JRXmlConstants.ATTRIBUTE_lineColor); if (lineColor != null && lineColor.length() > 0) { pen.setLineColor(JRColorUtil.getColor(lineColor, null)); } }
/** * */ public LineStyleEnum getLineStyleValue(JRPen pen) { LineStyleEnum ownLineStyle = pen.getOwnLineStyleValue(); if (ownLineStyle != null) { return ownLineStyle; } JRStyle baseStyle = getBaseStyle(pen); if (baseStyle != null) { LineStyleEnum lineStyle = baseStyle.getLinePen().getLineStyleValue(); if (lineStyle != null) { return lineStyle; } } return LineStyleEnum.SOLID; }
/** * */ public LineStyleEnum getLineStyleValue(JRBoxPen boxPen) { LineStyleEnum ownLineStyle = boxPen.getOwnLineStyleValue(); if (ownLineStyle != null) { return ownLineStyle; } LineStyleEnum penLineStyle = boxPen.getBox().getPen().getOwnLineStyleValue(); if (penLineStyle != null) { return penLineStyle; } JRStyle baseStyle = getBaseStyle(boxPen); if (baseStyle != null) { LineStyleEnum lineStyle = boxPen.getPen(baseStyle.getLineBox()).getLineStyleValue(); if (lineStyle != null) { return lineStyle; } } return LineStyleEnum.SOLID; }
private List<ComboItem> createLineSpacingItems(){ if (lineSpacingItems == null){ lineSpacingItems = new ArrayList<ComboItem>(); LineStyleEnum[] values = LineStyleEnum.class.getEnumConstants(); lineSpacingItems.add(new ComboItem(MessagesByKeys.getString("LineSpacing_nullEnum"), true, ResourceManager.getImage(this.getClass(),"/icons/resources/inherited.png"), 0, NullEnum.INHERITED, 0)); Image[] images = new Image[] { ResourceManager.getImage(this.getClass(), "/icons/resources/line-solid.png"), ResourceManager.getImage(this.getClass(), "/icons/resources/line-dashed.png"), ResourceManager.getImage(this.getClass(), "/icons/resources/line-dotted.png"), ResourceManager.getImage(this.getClass(), "/icons/resources/line-double.png"), }; for(int i=0; i<values.length; i++){ LineStyleEnum value = values[i]; lineSpacingItems.add(new ComboItem(MessagesByKeys.getString("LineStyle_".concat(value.getName())), true, images[i], i+1, value , i+1)); } } return lineSpacingItems; }
@Override public void createPropertyDescriptors(List<IPropertyDescriptor> desc, Map<String, Object> defaultsMap) { // pen ColorPropertyDescriptor penLineColorD = new ColorPropertyDescriptor(JRBasePen.PROPERTY_LINE_COLOR, Messages.common_line_color, NullEnum.INHERITED); penLineColorD.setDescription(Messages.MLinePen_line_color_description); penLineColorD.setHelpRefBuilder(new HelpReferenceBuilder("net.sf.jasperreports.doc/docs/schema.reference.html?cp=0_1#pen_lineColor")); desc.add(penLineColorD); FloatPropertyDescriptor penLineWidthD = new FloatPropertyDescriptor(JRBasePen.PROPERTY_LINE_WIDTH, Messages.MLinePen_line_width); penLineWidthD.setDescription(Messages.MLinePen_line_width_description); penLineWidthD.setHelpRefBuilder(new HelpReferenceBuilder("net.sf.jasperreports.doc/docs/schema.reference.html?cp=0_1#pen_lineWidth")); desc.add(penLineWidthD); penLineStyleD = new JSSPopupPropertyDescriptor(JRBasePen.PROPERTY_LINE_STYLE, Messages.common_line_style, LineStyleEnum.class, NullEnum.INHERITED, createLineSpacingItems()); penLineStyleD.setDescription(Messages.MLinePen_line_style_description); penLineStyleD.setHelpRefBuilder(new HelpReferenceBuilder("net.sf.jasperreports.doc/docs/schema.reference.html?cp=0_1#pen_lineStyle")); desc.add(penLineStyleD); defaultsMap.put(JRBasePen.PROPERTY_LINE_STYLE, null); defaultsMap.put(JRBasePen.PROPERTY_LINE_COLOR, null); defaultsMap.put(JRBasePen.PROPERTY_LINE_WIDTH, null); }
/** * Create the line style combo popup * @param prop properties associated to the combo popup * @param composite parent where the combo will be placed */ private void createLineStyle(final Composite composite) { List<ComboItem> itemsList = new ArrayList<ComboItem>(); //A blank space is added at the end of the string to compensate the size enlargement because a selected element is in bold itemsList.add(new ComboItem("Inherited ", true, ResourceManager.getImage(this.getClass(), "/icons/resources/inherited.png"),0, NullEnum.INHERITED, null)); itemsList.add(new ComboItem("Solid line ", true, ResourceManager.getImage(this.getClass(), "/icons/resources/line-solid.png"),1, LineStyleEnum.SOLID, new Integer(LineStyleEnum.SOLID.getValue() + 1))); itemsList.add(new ComboItem("Dashed line ", true, ResourceManager.getImage(this.getClass(), "/icons/resources/line-dashed.png"),2, LineStyleEnum.DASHED, new Integer(LineStyleEnum.DASHED.getValue() + 1))); itemsList.add(new ComboItem("Dotted line ", true, ResourceManager.getImage(this.getClass(), "/icons/resources/line-dotted.png"),3, LineStyleEnum.DOTTED, new Integer(LineStyleEnum.DOTTED.getValue() + 1))); itemsList.add(new ComboItem("Double line ", true, ResourceManager.getImage(this.getClass(), "/icons/resources/line-double.png"),4, LineStyleEnum.DOUBLE, new Integer(LineStyleEnum.DOUBLE.getValue() + 1))); //Creating the combo popup lineStyle = new ComboMenuViewer(composite, SWT.NORMAL, SPRWPopUpCombo.getLongest(itemsList)); lineStyle.setItems(itemsList); lineStyle.addSelectionListener(new ComboItemAction() { /** * The action to execute when an entry is selected */ @Override public void exec() { changeProperty(JRBasePen.PROPERTY_LINE_STYLE, lineStyle.getSelectionValue() != null ? (Integer)lineStyle.getSelectionValue() : null); callListeners(lineStyle.getControl(), JRBasePen.PROPERTY_LINE_STYLE); } }); lineStyle.select(1); }
private static LineStyleEnum getLineStyleValue(JRBoxPen boxPen) { LineStyleEnum ownLineStyle = boxPen.getOwnLineStyleValue(); if (ownLineStyle != null) { return ownLineStyle; } LineStyleEnum penLineStyle = boxPen.getBox().getPen().getOwnLineStyleValue(); if (penLineStyle != null) { return penLineStyle; } JRStyle baseStyle = JRStyleResolver.getBaseStyle(boxPen.getStyleContainer()); if (baseStyle != null) { LineStyleEnum lineStyle = boxPen.getPen(baseStyle.getLineBox()).getLineStyleValue(); if (lineStyle != null) { return lineStyle; } } return null; }
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (isSelected) { setForeground(selectionForeground); setBackground(selectionBackground); } else { setForeground(foreground); setBackground(background); } if (value instanceof LineStyleEnum) { styleName = (LineStyleEnum)value; } else { styleName = null; } repaint(); return this; }
protected void borderTest(String name, int index, Color topColor, LineStyleEnum topLineStyle, float top, Color bottomColor, LineStyleEnum bottomLineStyle, float bottom, Color leftColor, LineStyleEnum leftLineStyle, float left, Color rightColor, LineStyleEnum rightLineStyle, float right) { JRStyle style = getElementAt(name, index).getStyle(); JRBoxPen pen = style.getLineBox().getTopPen(); Assert.assertEquals(new Float(top), pen.getLineWidth()); Assert.assertEquals(topColor, pen.getLineColor()); Assert.assertEquals(topLineStyle, pen.getLineStyleValue()); pen = style.getLineBox().getBottomPen(); Assert.assertEquals(new Float(bottom), pen.getLineWidth()); Assert.assertEquals(bottomColor, pen.getLineColor()); Assert.assertEquals(bottomLineStyle, pen.getLineStyleValue()); pen = style.getLineBox().getLeftPen(); Assert.assertEquals(new Float(left), pen.getLineWidth()); Assert.assertEquals(leftColor, pen.getLineColor()); Assert.assertEquals(leftLineStyle, pen.getLineStyleValue()); pen = style.getLineBox().getRightPen(); Assert.assertEquals(new Float(right), pen.getLineWidth()); Assert.assertEquals(rightColor, pen.getLineColor()); Assert.assertEquals(rightLineStyle, pen.getLineStyleValue()); }
@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 test() { super.test(); numberOfPagesTest(1); //column1 styleTest("pageFooter.textField1", 0, null, null, "Arial", 10f, null, null); horizontalAlignmentTest("pageFooter.textField1", 0, HorizontalAlignEnum.RIGHT); paddingTest("pageFooter.textField1", 0, 2, 2, 2, 0); borderTest("pageFooter.textField1", 0, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 0); styleTest("pageFooter.textField2", 0, null, null, "Arial", 10f, null, null); horizontalAlignmentTest("pageFooter.textField2", 0, HorizontalAlignEnum.LEFT); paddingTest("pageFooter.textField2", 0, 2, 2, 0, 2); borderTest("pageFooter.textField2", 0, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 1, null, LineStyleEnum.SOLID, 0, null, LineStyleEnum.SOLID, 1); }
@Override public void test() { super.test(); numberOfPagesTest(1); //column1 columnTitleStyleTest(column1, 0, null, null, "Arial", 10f, true, null); columnTitlePaddingTest(column1, 0, 2, 2, 2, 2); columnDetailStyleTest(column1, 0, null, null, "Arial", 10f, null, null); columnDetailPaddingTest(column1, 0, 2, 2, 2, 2); //column2 groupHeaderStyleTest(group1, 0, null, null, "Arial", 10f, true, null); //subtotal subtotalLabelStyleTest(subtotal1, 0, null, null, "Arial", 10f, true, null); subtotalLabelBorderTest(subtotal1, 0, null, LineStyleEnum.SOLID, 0, null, LineStyleEnum.SOLID, 0, null, LineStyleEnum.SOLID, 0, null, LineStyleEnum.SOLID, 0); }
@Override public void test() { super.test(); numberOfPagesTest(1); //column1 columnTitleStyleTest(column1, 0, null, null, "Arial", 10f, true, null); columnTitlePaddingTest(column1, 0, 2, 2, 2, 2); columnDetailStyleTest(column1, 0, null, null, "Arial", 10f, null, null); columnDetailPaddingTest(column1, 0, 2, 2, 2, 2); //column2 groupHeaderStyleTest(group1, 0, null, null, "Arial", 10f, true, null); //subtotal subtotalLabelStyleTest(subtotal1, 0, null, null, "Arial", 10f, true, null); subtotalLabelBorderTest(subtotal1, 0, null, LineStyleEnum.SOLID, 0, null, LineStyleEnum.SOLID, 0, null, LineStyleEnum.SOLID, 0, null, LineStyleEnum.SOLID, 0); //title styleTest("title.textField1", 0, null, null, "Arial", 15f, true, null); styleTest("title.textField2", 0, null, null, "Arial", 10f, true, null); }
@Override public void setLineStyle(LineStyleEnum lineStyleValue) { Object old = this.lineStyleValue; this.lineStyleValue = lineStyleValue; getEventSupport().firePropertyChange(PROPERTY_LINE_STYLE, old, this.lineStyleValue); }
@SuppressWarnings("deprecation") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2) { lineStyleValue = LineStyleEnum.getByValue(lineStyle); lineStyle = null; } }
/** * */ private void addHorizontalGridLine(int x, int y, int width) { JRPrintFrame printFrame = new JRBasePrintFrame(getDefaultStyleProvider()); printFrame.setX(x); printFrame.setY(y); printFrame.setWidth(width); printFrame.setHeight(1); printFrame.getLineBox().getPen().setLineWidth(0); printFrame.getLineBox().getPen().setLineStyle(LineStyleEnum.SOLID); printFrame.getLineBox().getTopPen().setLineWidth(0.1f); printFrame.getLineBox().getTopPen().setLineStyle(LineStyleEnum.DASHED); printFrame.getLineBox().getTopPen().setLineColor(GRID_LINE_COLOR); pageElements.add(0, printFrame); }
/** * */ private void addVerticalGridLine(int x, int y, int height) { JRPrintFrame printFrame = new JRBasePrintFrame(getDefaultStyleProvider()); printFrame.setX(x); printFrame.setY(y); printFrame.setWidth(1); printFrame.setHeight(height); printFrame.getLineBox().getPen().setLineWidth(0); printFrame.getLineBox().getPen().setLineStyle(LineStyleEnum.SOLID); printFrame.getLineBox().getLeftPen().setLineWidth(0.1f); printFrame.getLineBox().getLeftPen().setLineStyle(LineStyleEnum.DASHED); printFrame.getLineBox().getLeftPen().setLineColor(GRID_LINE_COLOR); pageElements.add(0, printFrame); }
/** * */ protected void addContour(ReportConverter reportConverter, JRBasePrintFrame frame, JRPrintElement element) { if (frame != null) { boolean hasContour = false; JRLineBox box = element instanceof JRBoxContainer ? ((JRBoxContainer)element).getLineBox() : null; if (box == null) { JRPrintGraphicElement graphicElement = element instanceof JRPrintGraphicElement ? (JRPrintGraphicElement)element : null; hasContour = (graphicElement == null) || graphicElement.getLinePen().getLineWidth().floatValue() <= 0f; } else { hasContour = box.getTopPen().getLineWidth().floatValue() <= 0f && box.getLeftPen().getLineWidth().floatValue() <= 0f && box.getRightPen().getLineWidth().floatValue() <= 0f && box.getBottomPen().getLineWidth().floatValue() <= 0f; } if (hasContour) { JRBasePrintRectangle rectangle = new JRBasePrintRectangle(reportConverter.getDefaultStyleProvider()); rectangle.setUUID(element.getUUID()); rectangle.setX(element.getX()); rectangle.setY(element.getY()); rectangle.setWidth(element.getWidth()); rectangle.setHeight(element.getHeight()); rectangle.getLinePen().setLineWidth(0.1f); rectangle.getLinePen().setLineStyle(LineStyleEnum.DASHED); rectangle.getLinePen().setLineColor(ReportConverter.GRID_LINE_COLOR); rectangle.setMode(ModeEnum.TRANSPARENT); frame.addElement(rectangle); } } }
/** * Create the component and initialize the combo popup with the necessary value * @param parent composite where the combo popup is palced * @param section section that contains the property that this combo will change when an entry is selected * @param property id of the property that this combo will change when an entry is selected */ public void createComponent(Composite parent, final AbstractSection section, final String property) { Composite composite = new Composite(parent, SWT.NONE); RowLayout layout = new RowLayout(); layout.marginLeft = 0; composite.setLayout(layout); //Creating the list of entry List<ComboItem> itemsList = new ArrayList<ComboItem>(); //A blank space is added at the end of the string to compensate the size enlargement because a selected element is in bold itemsList.add(new ComboItem("Inherited ", true, ResourceManager.getImage(this.getClass(), "/icons/resources/inherited.png"),0, NullEnum.INHERITED, null)); itemsList.add(new ComboItem("Solid line ", true, ResourceManager.getImage(this.getClass(), "/icons/resources/line-solid.png"),1, LineStyleEnum.SOLID, new Integer(LineStyleEnum.SOLID.getValue() + 1))); itemsList.add(new ComboItem("Dashed line ", true, ResourceManager.getImage(this.getClass(), "/icons/resources/line-dashed.png"),2, LineStyleEnum.DASHED, new Integer(LineStyleEnum.DASHED.getValue() + 1))); itemsList.add(new ComboItem("Dotted line ", true, ResourceManager.getImage(this.getClass(), "/icons/resources/line-dotted.png"),3, LineStyleEnum.DOTTED, new Integer(LineStyleEnum.DOTTED.getValue() + 1))); itemsList.add(new ComboItem("Double line ", true, ResourceManager.getImage(this.getClass(), "/icons/resources/line-double.png"),4, LineStyleEnum.DOUBLE, new Integer(LineStyleEnum.DOUBLE.getValue() + 1))); //Creating the combo popup combo = new ComboMenuViewer(composite, SWT.NORMAL, SPRWPopUpCombo.getLongest(itemsList)); combo.setItems(itemsList); combo.addSelectionListener(new ComboItemAction() { /** * The action to execute when an entry is selected */ @Override public void exec() { propertyChange(section,JRBasePen.PROPERTY_LINE_STYLE, combo.getSelectionValue() != null ? (Integer)combo.getSelectionValue() : null); } }); }
/** * Used when no border is selected to fined an intersection of the value of the borders * * @param lb the linebox * @return a pen with the intersection values */ private JRBoxPen getIntesectionValues(MLineBox lb){ if (lb != null && lb.getValue() != null){ JRLineBox jrLineBox = (JRLineBox)lb.getValue(); List<JRBoxPen> edgePen = new ArrayList<JRBoxPen>(); edgePen.add(jrLineBox.getLeftPen()); edgePen.add(jrLineBox.getRightPen()); edgePen.add(jrLineBox.getTopPen()); edgePen.add(jrLineBox.getBottomPen()); Color intersectionLineColor = null; LineStyleEnum intersectionLineStyle = null; Float intersectionLineWidth = null; JRBoxPen resultPen = null; for(JRBoxPen pen : edgePen){ if (pen != null){ resultPen = pen; if (intersectionLineColor != null && !intersectionLineColor.equals(pen.getLineColor())){ resultPen = null; break; } if (intersectionLineStyle != null && !intersectionLineStyle.equals(pen.getLineStyleValue())){ resultPen = null; break; } if (intersectionLineWidth != null && !intersectionLineWidth.equals(pen.getLineWidth())){ resultPen = null; break; } intersectionLineColor = pen.getLineColor(); intersectionLineStyle = pen.getLineStyleValue(); intersectionLineWidth = pen.getLineWidth(); } } if (resultPen == null && jrLineBox.getPen() != null) return jrLineBox.getPen(); return resultPen; } return null; }
public void refreshLinePen(JRBoxPen pen) { if (pen != null) { Float width = pen.getLineWidth(); // Set the border data only if it is visible if (lineWidth != null && !lineWidth.isDisposed()) { if (width == null) { lineWidth.setValues(0, 0, 5000, 1, 1, 1); } else { UIUtil.setSpinnerSelection(lineWidth, null, (int) (width.doubleValue() * Math.pow(10, 1))); } } if (lineStyle != null && !isDisposed()) { if (pen.getLineStyleValue() == null) { lineStyle.setData(1); } else { int ls = EnumHelper.getValue(pen.getLineStyleValue(), LineStyleEnum.SOLID.getValue(), true).intValue(); lineStyle.setData(ls); } } if (lineColor != null && !lineColor.getPaintArea().isDisposed()) { if (pen.getLineColor() == null) { lineColor.setColor(AlfaRGB.getFullyOpaque(new RGB(0, 0, 0))); } else { AlfaRGB backcolor = Colors.getSWTRGB4AWTGBColor(pen.getLineColor()); lineColor.setColor(backcolor); } } } }
public void setPropertyValue(Object id, Object value) { JRPen linePen = (JRPen) getValue(); if (linePen != null) { if (id.equals(JRBasePen.PROPERTY_LINE_WIDTH)) linePen.setLineWidth(((Float) value)); else if (id.equals(JRBasePen.PROPERTY_LINE_COLOR)) { if (value == null) linePen.setLineColor(null); else if (value instanceof AlfaRGB) linePen.setLineColor(Colors.getAWT4SWTRGBColor((AlfaRGB) value)); } else if (id.equals(JRBasePen.PROPERTY_LINE_STYLE)) linePen.setLineStyle((LineStyleEnum) penLineStyleD.getEnumValue(value)); } }
private String getPenXML(String tagName, JRBoxPen value){ LineStyleEnum style = value.getOwnLineStyleValue() != null ? value.getOwnLineStyleValue() : LineStyleEnum.SOLID; float lineWidth = value.getOwnLineWidth() != null ? value.getOwnLineWidth() : 0f; Color color = value.getOwnLineColor() != null ? value.getOwnLineColor() : new Color(0, 0, 0); String result = "<"+tagName+" lineStyle=\"" + style.getValueByte() +"\" "; result += "lineWidth=\""+lineWidth+"\">"; result += xmlColor("lineColor", colorToAlfaRGB(color)); result += "</"+tagName+">"; return result; }
private static void buildPen(Node xmlPenNode, JRBoxPen sourcePen){ NamedNodeMap penAttributes = xmlPenNode.getAttributes(); LineStyleEnum lineStyle = LineStyleEnum.getByValue(Byte.valueOf(penAttributes.getNamedItem("lineStyle").getNodeValue())); float lineWidth = Float.parseFloat(penAttributes.getNamedItem("lineWidth").getNodeValue()); AlfaRGB lineColor = null; Node firstChild = xmlPenNode.getFirstChild(); if (firstChild != null && firstChild.getNodeName().equals("lineColor")){ lineColor = rgbColor(firstChild); } if (lineColor != null) sourcePen.setLineColor(alfaRGBtoColor(lineColor)); sourcePen.setLineStyle(lineStyle); sourcePen.setLineWidth(lineWidth); }
/** * Convert a line style enum to an integer * * @param style the line style enum * @return an integer from 1 to 4 */ private int lineStyletoInt(LineStyleEnum style){ if (style.equals(LineStyleEnum.SOLID)) return 1; if (style.equals(LineStyleEnum.DASHED)) return 2; if (style.equals(LineStyleEnum.DOTTED)) return 3; if (style.equals(LineStyleEnum.DOUBLE)) return 4; return 0; }
/** * Convert an integer to a line style * * @param value an integer value from 1 to 4 * @return a line style enum */ private LineStyleEnum intToLinestyleEnum(int value){ if (value == 1) return LineStyleEnum.SOLID; if (value == 2) return LineStyleEnum.DASHED; if (value == 3) return LineStyleEnum.DOTTED; if (value == 4) return LineStyleEnum.DOUBLE; return null; }
private TemplateBorder getElementAttribute(String position, MLineBox lb){ MLinePen lp = (MLinePen) lb.getPropertyValue(position); Integer lineStyleNum = ((Integer)lp.getPropertyValue(JRBasePen.PROPERTY_LINE_STYLE))-1; LineStyleEnum lineStyle = LineStyleEnum.getByValue(lineStyleNum.byteValue()); Float lineWidth = (Float)lp.getPropertyValue(JRBasePen.PROPERTY_LINE_WIDTH); AlfaRGB lineColor = (AlfaRGB)lp.getPropertyValue(JRBasePen.PROPERTY_LINE_COLOR); TemplateBorder result = new TemplateBorder(lineWidth, lineStyle, lineColor != null ? lineColor.getRgb() : null); return result; }
public static void applyDiff(JRPen main, JRPen from) { // Paddings... if (main.getOwnLineColor() != null && !main.getOwnLineColor().equals(from.getOwnLineColor())) main.setLineColor(null); if (main.getOwnLineWidth() != null && !main.getOwnLineWidth().equals(from.getOwnLineWidth())) main.setLineWidth(null); if (main.getOwnLineStyleValue() != null && main.getOwnLineStyleValue() != from.getOwnLineStyleValue()) main.setLineStyle((LineStyleEnum)null); }
public void resetPen(JRPen pen) { if (pen == null) return; pen.setLineColor(null); pen.setLineStyle((LineStyleEnum)null); pen.setLineWidth(null); }
public void setPen(JRPen mpen) { if (mpen != null) { pen.setLineColor( mpen.getOwnLineColor()); pen.setLineWidth( mpen.getOwnLineWidth()); pen.setLineStyle( mpen.getOwnLineStyleValue()); } else { pen.setLineColor( null ); pen.setLineWidth( null ); pen.setLineStyle( (LineStyleEnum)null ); } }
@Override public void test() { super.test(); numberOfPagesTest(1); JasperPrint jasperPrint = getJasperPrint(); Assert.assertEquals("templatedesign6", jasperPrint.getName()); styleTest("templateDesign.title1", 0, Color.BLACK, Color.LIGHT_GRAY, "SansSerif", null, true, null); borderTest("templateDesign.title1", 0, Color.BLACK, LineStyleEnum.SOLID, 2, Color.BLACK, LineStyleEnum.SOLID, 2, Color.BLACK, LineStyleEnum.SOLID, 2, Color.BLACK, LineStyleEnum.SOLID, 2); styleTest("templateDesign.title2", 0, null, Color.RED, "SansSerif", null, null, null); }
@Override public LineStyleEnum getLineStyleValue() { return getStyleResolver().getLineStyleValue(this); }
@Override public LineStyleEnum getOwnLineStyleValue() { return lineStyleValue; }
/** * */ public static LineStyleEnum getLineStyleValue(JRPen pen) { return styleResolver.getLineStyleValue(pen); }
/** * */ public static LineStyleEnum getLineStyleValue(JRBoxPen boxPen) { return styleResolver.getLineStyleValue(boxPen); }
/** * */ public static void setLinePenFromPen(PenEnum pen, JRPen linePen) { if (pen != null) { switch (pen) { case THIN : { linePen.setLineWidth(0.5f); linePen.setLineStyle(LineStyleEnum.SOLID); break; } case ONE_POINT : { linePen.setLineWidth(1f); linePen.setLineStyle(LineStyleEnum.SOLID); break; } case TWO_POINT : { linePen.setLineWidth(2f); linePen.setLineStyle(LineStyleEnum.SOLID); break; } case FOUR_POINT : { linePen.setLineWidth(4f); linePen.setLineStyle(LineStyleEnum.SOLID); break; } case DOTTED : { linePen.setLineWidth(1f); linePen.setLineStyle(LineStyleEnum.DASHED); break; } case NONE : { linePen.setLineWidth(0f); linePen.setLineStyle(LineStyleEnum.SOLID); break; } } } }
/** * */ protected void exportRectangle(JRPrintRectangle rectangle) { pdfContentByte.setRGBColorFill( rectangle.getBackcolor().getRed(), rectangle.getBackcolor().getGreen(), rectangle.getBackcolor().getBlue() ); preparePen(pdfContentByte, rectangle.getLinePen(), PdfContentByte.LINE_CAP_PROJECTING_SQUARE); float lineWidth = rectangle.getLinePen().getLineWidth().floatValue(); int lcOffsetX = getOffsetX(); int lcOffsetY = getOffsetY(); if (rectangle.getModeValue() == ModeEnum.OPAQUE) { pdfContentByte.roundRectangle( rectangle.getX() + lcOffsetX, pageFormat.getPageHeight() - rectangle.getY() - lcOffsetY - rectangle.getHeight(), rectangle.getWidth(), rectangle.getHeight(), rectangle.getRadius() ); pdfContentByte.fill(); } if (lineWidth > 0f) { if (rectangle.getLinePen().getLineStyleValue() == LineStyleEnum.DOUBLE) { pdfContentByte.roundRectangle( rectangle.getX() + lcOffsetX - lineWidth / 3, pageFormat.getPageHeight() - rectangle.getY() - lcOffsetY - rectangle.getHeight() - lineWidth / 3, rectangle.getWidth() + 2 * lineWidth / 3, rectangle.getHeight() + 2 * lineWidth / 3, rectangle.getRadius() ); pdfContentByte.stroke(); pdfContentByte.roundRectangle( rectangle.getX() + lcOffsetX + lineWidth / 3, pageFormat.getPageHeight() - rectangle.getY() - lcOffsetY - rectangle.getHeight() + lineWidth / 3, rectangle.getWidth() - 2 * lineWidth / 3, rectangle.getHeight() - 2 * lineWidth / 3, rectangle.getRadius() ); pdfContentByte.stroke(); } else { pdfContentByte.roundRectangle( rectangle.getX() + lcOffsetX, pageFormat.getPageHeight() - rectangle.getY() - lcOffsetY - rectangle.getHeight(), rectangle.getWidth(), rectangle.getHeight(), rectangle.getRadius() ); pdfContentByte.stroke(); } } pdfContentByte.setLineDash(0f); }