Java 类net.sf.jasperreports.engine.base.JRBoxPen 实例源码

项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public Float getLineWidth(JRBoxPen boxPen, Float defaultLineWidth)
{
    Float ownLineWidth = boxPen.getOwnLineWidth();
    if (ownLineWidth != null)
    {
        return ownLineWidth;
    }
    Float penLineWidth = boxPen.getBox().getPen().getOwnLineWidth();
    if (penLineWidth != null) 
    {
        return penLineWidth;
    }
    JRStyle baseStyle = getBaseStyle(boxPen);
    if (baseStyle != null)
    {
        Float lineWidth = boxPen.getPen(baseStyle.getLineBox()).getLineWidth();
        if (lineWidth != null)
        {
            return lineWidth;
        }
    }
    return defaultLineWidth;
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
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;
}
项目:jasperreports    文件:StyleResolver.java   
/**
 *
 */
public Color getLineColor(JRBoxPen boxPen, Color defaultColor)
{
    //FIXMENOW line color is resolved to base style forecolor before current pen container forecolor; 
    // for example, rectangle with blue forecolor would have border drawn in red, if it uses style with red forecolor
    Color ownLineColor = boxPen.getOwnLineColor();
    if (ownLineColor != null)
    {
        return ownLineColor;
    }
    Color penLineColor = boxPen.getBox().getPen().getOwnLineColor();
    if (penLineColor != null)
    {
        return penLineColor;
    }
    JRStyle baseStyle = getBaseStyle(boxPen);
    if (baseStyle != null)
    {
        Color lineColor = boxPen.getPen(baseStyle.getLineBox()).getLineColor();
        if (lineColor != null)
        {
            return lineColor;
        }
    }
    return defaultColor;
}
项目:PDFReporter-Studio    文件:BordersWidget.java   
/**
 * Update the right panel with the value of a linepen, but only if it's visible
 * @param lb
 * @param property
 */
public void refreshLinePen(JRBoxPen lp) {
    if (lp != null) {
        Float propertyValue = lp.getOwnLineWidth() != null ? lp.getOwnLineWidth() : 0;
        if (propertyValue>0){
            //Set the border data only if it is visible
            if (lineWidth != null && !lineWidth.isDisposed()) {
                UIUtil.setSpinnerSelection(lineWidth, null, (int) ((propertyValue == null) ? 0 : propertyValue.doubleValue()
                        * Math.pow(10, 1)));
            }

            if (lineStyle != null && !isDisposed()) {
                int ls = lp.getOwnLineStyleValue() != null ? lineStyletoInt(lp.getOwnLineStyleValue()): 0;
                lineStyle.select(ls);
            }
            Color awtColor = lp.getOwnLineColor();
            AlfaRGB backcolor = awtColor != null ? new AlfaRGB(new RGB(awtColor.getRed(), awtColor.getGreen(), awtColor.getBlue()), awtColor.getAlpha()) : AlfaRGB.getFullyOpaque(new RGB(0,0,0));
            if (lineColor != null){
                lineColor.setColor(backcolor);
            }
        }
    }
}
项目:PDFReporter-Studio    文件:CustomStyleResolver.java   
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;
}
项目:dynamicreports-jasper    文件:AbstractJasperStyleTest.java   
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());
}
项目:dynamicreports-jasper    文件:AdhocReportLoadTest.java   
@Override
@Test
public void test() {
    numberOfPagesTest(1);

    elementValueTest("columnHeader.column_field1.title1", 0, "Column1 && C<a>aa</a> \"a\" 'c'");
    elementValueTest("columnHeader.column_field2.title1", 0, "Column2");

    elementValueTest("detail.column_field11", 0, "test");
    elementValueTest("detail.column_field21", 0, "1");
    elementValueTest("detail.column_field31", 0, new SimpleDateFormat("M/d/yy h:mm a", new DateFormatSymbols(Locale.ENGLISH)).format(toDate(2011, 1, 1)));

    elementValueTest("groupHeaderTitleAndValue.group_" + groupName + "1", "test");

    JRStyle style = getElementAt("columnHeader.column_field1.title1", 0).getStyle();
    JRBoxPen pen = style.getLineBox().getLeftPen();
    Assert.assertEquals(2f, pen.getLineWidth());
    style = getElementAt("detail.column_field11", 0).getStyle();
    Assert.assertEquals("foreColor", Color.BLUE, style.getForecolor());
}
项目:dynamicreports-jasper    文件:AdhocReportTest.java   
@Override
@Test
public void test() {
    numberOfPagesTest(1);

    elementValueTest("columnHeader.column_field1.title1", 0, "Column1 && C<a>aa</a> \"a\" 'c'");
    elementValueTest("columnHeader.column_field2.title1", 0, "Column2");

    elementValueTest("detail.column_field11", 0, "test");
    elementValueTest("detail.column_field21", 0, "1");
    elementValueTest("detail.column_field31", 0, new SimpleDateFormat("M/d/yy h:mm a", new DateFormatSymbols(Locale.ENGLISH)).format(toDate(2011, 1, 1)));

    elementValueTest("groupHeaderTitleAndValue.group_" + groupName + "1", "test");

    JRStyle style = getElementAt("columnHeader.column_field1.title1", 0).getStyle();
    JRBoxPen pen = style.getLineBox().getLeftPen();
    Assert.assertEquals(2f, pen.getLineWidth());
    style = getElementAt("detail.column_field11", 0).getStyle();
    Assert.assertEquals("foreColor", Color.BLUE, style.getForecolor());
}
项目:PDFReporter-Studio    文件:BordersSection.java   
/**
 * Update the value on the right panel with the selected line data
 */
private void updateRightPanel(){
    APropertyNode m = getElement();
    if (m != null) {
        MLineBox lb = (MLineBox) m.getPropertyActualValue(MGraphicElementLineBox.LINE_BOX);
        if (bd.getLastSelected() != null && bd.getLastSelected().getSelected()) {
            refreshLinePen(lb, locationToLine(bd.getLastSelected().getLocation()));
        }
        else if (bd.isTopSelected()) {
            refreshLinePen(lb, MLineBox.LINE_PEN_TOP);
        }
        else if (bd.isBottomSelected()) {
            refreshLinePen(lb, MLineBox.LINE_PEN_BOTTOM);
        }
        else if (bd.isLeftSelected()) {
            refreshLinePen(lb, MLineBox.LINE_PEN_LEFT);
        }
        else if (bd.isRightSelected()) {
            refreshLinePen(lb, MLineBox.LINE_PEN_RIGHT);
        }
        else {
            //No border is selected, set the control to the default value
            JRBoxPen pen = getIntesectionValues(lb);
            if (pen != null){
                refreshLinePen(pen);
            } else {    
                lineColor.setColor(AlfaRGB.getFullyOpaque(new RGB(0, 0, 0)));
                lineWidth.setValues(0, 0, 5000, 1, 1, 1);
                lineStyle.setData(1);
            }
        }
    }
}
项目:PDFReporter-Studio    文件:BordersSection.java   
/**
 * 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;
}
项目:PDFReporter-Studio    文件:BordersSection.java   
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);
            }
        }
    }
}
项目:PDFReporter-Studio    文件:TextStyle.java   
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;
}
项目:PDFReporter-Studio    文件:TextStyle.java   
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);
}
项目:PDFReporter-Studio    文件:TextStyle.java   
private boolean equalsPen(JRBoxPen pen1, JRBoxPen pen2){
    if (pen1 == null) return pen2 == null;
    if (pen2 == null) return pen1 == null;
    if (!AbstractResourceDefinition.safeEquals(pen1.getOwnLineColor(),pen2.getOwnLineColor())) return false;
    if (!AbstractResourceDefinition.safeEquals(pen1.getOwnLineStyleValue(),pen2.getOwnLineStyleValue())) return false;
    if (!AbstractResourceDefinition.safeEquals(pen1.getOwnLineWidth(), pen2.getOwnLineWidth())) return false;
    return true;
}
项目:PDFReporter-Studio    文件:TextStyle.java   
private void copyLinePen(JRBoxPen originPen, JRBoxPen destinationPen){
    Color newColor = null;
    Color originLineColor = originPen.getOwnLineColor();
    if (originLineColor != null) newColor = new Color(originLineColor.getRed(), originLineColor.getGreen(), originLineColor.getBlue(), originLineColor.getAlpha());
    destinationPen.setLineColor(newColor);
    destinationPen.setLineStyle(originPen.getOwnLineStyleValue());
    destinationPen.setLineWidth(originPen.getOwnLineWidth() != null ? new Float(originPen.getOwnLineWidth()) : null);
}
项目:PDFReporter-Studio    文件:BordersWidget.java   
/**
 * Set a property of a JRBoxPen element
 * 
 * @param pen the element
 * @param property the id of the property to set
 * @param value the value of the property
 */
private void setLinePenAttribute(JRBoxPen pen, String property, Object value){
    if (JRBasePen.PROPERTY_LINE_STYLE.equals(property)) pen.setLineStyle(intToLinestyleEnum((Integer)value));
    else if (JRBasePen.PROPERTY_LINE_COLOR.equals(property)) {
        AlfaRGB argbColor = (AlfaRGB) value;
        pen.setLineColor(new Color(argbColor.getRgb().red,argbColor.getRgb().green,argbColor.getRgb().blue,argbColor.getAlfa()));
    } else if (JRBasePen.PROPERTY_LINE_WIDTH.equals(property)) pen.setLineWidth((Float)value); 
}
项目:PDFReporter-Studio    文件:BordersWidget.java   
/**
 * Convert a border location to the corresponding line pen location
 * @param loc location of a border
 * @return a line pen location
 */
private JRBoxPen locationToLine(Location loc){
    JRLineBox borders = element.getBorders();
    if (loc == Location.TOP) return borders.getTopPen();
    else if (loc == Location.BOTTOM) return borders.getBottomPen();
    else if (loc == Location.RIGHT) return borders.getRightPen();
    else return borders.getLeftPen();
}
项目:PDFReporter-Studio    文件:CustomStyleResolver.java   
private static void inheritLinePenProeprties(JRPen jrPenTarget, JRPen jrStylePen){
    if (jrPenTarget != null && jrStylePen != null){
        if (jrPenTarget.getOwnLineColor() == null) jrPenTarget.setLineColor(JRStyleResolver.getLineColor(jrStylePen, null));
        if (jrPenTarget.getOwnLineStyleValue() == null) jrPenTarget.setLineStyle(getLineStyleValue((JRBoxPen)jrStylePen));
        if (jrPenTarget.getOwnLineWidth() == null) jrPenTarget.setLineWidth(JRStyleResolver.getLineWidth(jrStylePen, null));
    }
}
项目:jasperreports    文件:JRStyleResolver.java   
/**
 *
 */
public static Float getLineWidth(JRBoxPen boxPen, Float defaultLineWidth)
{
    return styleResolver.getLineWidth(boxPen, defaultLineWidth);
}
项目:jasperreports    文件:JRStyleResolver.java   
/**
 *
 */
public static LineStyleEnum getLineStyleValue(JRBoxPen boxPen)
{
    return styleResolver.getLineStyleValue(boxPen);
}
项目:jasperreports    文件:JRStyleResolver.java   
/**
 *
 */
public static Color getLineColor(JRBoxPen boxPen, Color defaultColor)
{
    return styleResolver.getLineColor(boxPen, defaultColor);
}
项目:jasperreports    文件:StyleUtil.java   
@Override
public JRBoxPen getPen(JRLineBox lineBox)
{
    return lineBox.getRightPen();
}
项目:jasperreports    文件:StyleUtil.java   
@Override
public JRBoxPen getPen(JRLineBox lineBox)
{
    return lineBox.getTopPen();
}
项目:jasperreports    文件:StyleUtil.java   
@Override
public JRBoxPen getPen(JRLineBox lineBox)
{
    return lineBox.getLeftPen();
}
项目:jasperreports    文件:StyleUtil.java   
@Override
public JRBoxPen getPen(JRLineBox lineBox)
{
    return lineBox.getBottomPen();
}
项目:jasperreports    文件:CachingLineBox.java   
@Override
public JRBoxPen getPen()
{
    return base.getPen();
}
项目:jasperreports    文件:CachingLineBox.java   
@Override
public void copyPen(JRBoxPen pen)
{
    throw new UnsupportedOperationException();
}
项目:jasperreports    文件:CachingLineBox.java   
@Override
public JRBoxPen getTopPen()
{
    return base.getTopPen();
}
项目:jasperreports    文件:CachingLineBox.java   
@Override
public void copyTopPen(JRBoxPen topPen)
{
    throw new UnsupportedOperationException();
}
项目:jasperreports    文件:CachingLineBox.java   
@Override
public JRBoxPen getLeftPen()
{
    return base.getLeftPen();
}
项目:jasperreports    文件:CachingLineBox.java   
@Override
public void copyLeftPen(JRBoxPen leftPen)
{
    throw new UnsupportedOperationException();
}
项目:jasperreports    文件:CachingLineBox.java   
@Override
public JRBoxPen getBottomPen()
{
    return base.getBottomPen();
}
项目:jasperreports    文件:CachingLineBox.java   
@Override
public void copyBottomPen(JRBoxPen bottomPen)
{
    throw new UnsupportedOperationException();
}
项目:jasperreports    文件:CachingLineBox.java   
@Override
public JRBoxPen getRightPen()
{
    return base.getRightPen();
}
项目:jasperreports    文件:CachingLineBox.java   
@Override
public void copyRightPen(JRBoxPen rightPen)
{
    throw new UnsupportedOperationException();
}
项目:jasperreports    文件:JRLineBox.java   
/**
 * Gets the pen properties for the border.
 */
public JRBoxPen getPen();
项目:jasperreports    文件:JRLineBox.java   
/**
 *
 */
public void copyPen(JRBoxPen pen);
项目:jasperreports    文件:JRLineBox.java   
/**
 * Gets the pen properties for the top border.
 */
public JRBoxPen getTopPen();
项目:jasperreports    文件:JRLineBox.java   
/**
 *
 */
public void copyTopPen(JRBoxPen topPen);
项目:jasperreports    文件:JRLineBox.java   
/**
 * Gets the pen properties for the left border.
 */
public JRBoxPen getLeftPen();