Java 类net.sf.jasperreports.engine.util.JRColorUtil 实例源码

项目:jasperreports    文件:HtmlElementHtmlHandler.java   
@Override
public String getHtmlFragment(JRHtmlExporterContext exporterContext,
        JRGenericPrintElement element)
{
    StringBuilder script = new StringBuilder(128);
    String htmlContent = (String) element.getParameterValue(HtmlPrintElement.PARAMETER_HTML_CONTENT);

    script.append("<div style='width:" + (element.getWidth() - 0) + "px;height:" + (element.getHeight() - 0) + "px;");

    if (element.getModeValue() == ModeEnum.OPAQUE)
    {
        script.append("background-color: #");
        script.append(JRColorUtil.getColorHexa(element.getBackcolor()));
        script.append("; ");
    }
    script.append("overflow:hidden;'>");
    script.append(htmlContent);
    script.append("</div>");

    return script.toString();
}
项目:jasperreports    文件:JRItemLabelFactory.java   
@Override
    public Object createObject(Attributes atts)
    {
        JRDesignItemLabel itemLabel = new JRDesignItemLabel(null, ((JRChartPlot)digester.peek()).getChart());

        String color = atts.getValue(ATTRIBUTE_color);
        if (color != null && color.length() > 0)
        {
            itemLabel.setColor(JRColorUtil.getColor(color, null));
        }

        String backgroundColor = atts.getValue(ATTRIBUTE_backgroundColor);
        if (backgroundColor != null && backgroundColor.length() > 0)
        {
            itemLabel.setBackgroundColor(JRColorUtil.getColor(backgroundColor, null));
        }

//      String mask = atts.getValue(ATTRIBUTE_mask);
//      if (mask != null && mask.length() > 0)
//      {
//          itemLabel.setMask(mask);
//      }
        return itemLabel;
    }
项目:jasperreports    文件:JRMeterIntervalFactory.java   
@Override
public Object createObject(Attributes atts)
{
    JRMeterInterval interval = new JRMeterInterval();

    String value = atts.getValue(ATTRIBUTE_label);
    if (value != null && value.length() > 0)
    {
        interval.setLabel(value);
    }

    value = atts.getValue(ATTRIBUTE_color);
    if (value != null && value.length() > 0)
    {
        interval.setBackgroundColor(JRColorUtil.getColor(value, null));
    }

    value = atts.getValue(ATTRIBUTE_alpha);
    if (value != null && value.length() > 0)
    {
        interval.setAlpha(Double.valueOf(value));
    }

    return interval;
}
项目:jasperreports    文件:JRValueDisplayFactory.java   
@Override
public Object createObject(Attributes atts)
{
    JRDesignValueDisplay valueDisplay = new JRDesignValueDisplay(null, ((JRChartPlot)digester.peek()).getChart());

    String color = atts.getValue(ATTRIBUTE_color);
    if (color != null && color.length() > 0)
    {
        valueDisplay.setColor(JRColorUtil.getColor(color, null));
    }

    String mask = atts.getValue(ATTRIBUTE_mask);
    if (mask != null && mask.length() > 0)
    {
        valueDisplay.setMask(mask);
    }

    return valueDisplay;
}
项目:jasperreports    文件:JRChartFactory.java   
@Override
public Object createObject(Attributes atts)
{
    JRDesignChart chart = (JRDesignChart) digester.peek();

    EdgeEnum position = EdgeEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_position));
    if (position != null)
    {
        chart.setTitlePosition(position);
    }

    Color color = JRColorUtil.getColor(atts.getValue(JRXmlConstants.ATTRIBUTE_color), Color.black);
    if (color != null)
    {
        chart.setTitleColor(color);
    }

    return chart;
}
项目:jasperreports    文件:JRPenFactory.java   
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));
    }
}
项目:jasperreports    文件:JRChartPlotFactory.java   
@Override
public Object createObject(Attributes atts)
{
    int seriesIndex = -1;
    Color color = null;

    String seriesNumber = atts.getValue(JRXmlConstants.ATTRIBUTE_seriesOrder);
    if (seriesNumber != null && seriesNumber.length() > 0)
    {
        seriesIndex = Integer.valueOf(seriesNumber).intValue();
    }
    String colorName = atts.getValue(JRXmlConstants.ATTRIBUTE_color);
    if (colorName != null && colorName.length() > 0)
    {
        color = JRColorUtil.getColor(colorName, null);
    }

    return new JRBaseChartPlot.JRBaseSeriesColor(seriesIndex, color);
}
项目:jasperreports    文件:HtmlExporter.java   
protected void writeSvgStyle(JRPrintGraphicElement element) throws IOException
{
    writer.write("style=\"fill:" + JRColorUtil.getCssColor(element.getBackcolor()) + ";");
    writer.write("stroke:" + JRColorUtil.getCssColor(element.getLinePen().getLineColor()) + ";");
    writer.write("stroke-width:" + element.getLinePen().getLineWidth() + ";");

    switch (element.getLinePen().getLineStyleValue())
    {
        case DOTTED :
        {
            writer.write("stroke-dasharray:" + element.getLinePen().getLineWidth() + "," + element.getLinePen().getLineWidth() + ";");
            break;
        }
        case DASHED :
        {
            writer.write("stroke-dasharray:" + 5 * element.getLinePen().getLineWidth() + "," + 3 * element.getLinePen().getLineWidth() + ";");
            break;
        }
        case DOUBLE : //FIXME: there is no built-in svg support for double stroke style; strokes could be rendered twice as a workaround
        case SOLID :
        default :
        {
            break;
        }
    }
}
项目:jasperreports    文件:XlsxFontInfo.java   
/**
 *
 */
public XlsxFontInfo(JRExporterGridCell gridCell, String fontName, boolean isFontSizeFixEnabled)
{
    JRPrintElement element = gridCell.getElement();

    if (element != null)
    {
        this.color = JRColorUtil.getColorHexa(element.getForecolor());
    }

    JRFont font = element instanceof JRFont ? (JRFont)element : null;
    if (font != null)
    {
        this.fontName = fontName;
        this.fontSize = font.getFontsize() + (isFontSizeFixEnabled ? -1 : 0);
        this.isBold = font.isBold();
        this.isItalic = font.isItalic();
        this.isUnderline = font.isUnderline();
        this.isStrikeThrough = font.isStrikeThrough();
    }
}
项目:jasperreports    文件:ChartSettingsXmlFactory.java   
@Override
public Object createObject(Attributes atts)
{
    StandardChartSettings chartSettings = (StandardChartSettings) digester.peek();

    EdgeEnum position = EdgeEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_position));
    if (position != null)
    {
        chartSettings.setTitlePosition(position);
    }

    Color color = JRColorUtil.getColor(atts.getValue(JRXmlConstants.ATTRIBUTE_color), Color.black);
    if (color != null)
    {
        chartSettings.setTitleColor(color);
    }

    return chartSettings;
}
项目:jasperreports    文件:QRCodeRasterizedImageProducer.java   
public BufferedImage getImage(BitMatrix matrix, Color onColor) 
{
    int width = matrix.getWidth();
    int height = matrix.getHeight();
    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    int onArgb = JRColorUtil.getOpaqueArgb(onColor, Color.BLACK);//not actually opaque
    for (int x = 0; x < width; x++) 
    {
        for (int y = 0; y < height; y++) 
        {
            if (matrix.get(x, y))
            {
                image.setRGB(x, y, onArgb);
            }
        }
    }
    return image;
}
项目: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    文件:FillXYSeries.java   
/**
 *
 */
protected void evaluate(JRCalculator calculator) throws JRExpressionEvalException
{
    series = (Comparable<?>)calculator.evaluate(getSeriesExpression()); 
    xValue = (Number)calculator.evaluate(getXValueExpression()); 
    yValue = (Number)calculator.evaluate(getYValueExpression());
    color = JRColorUtil.getColor((String)calculator.evaluate(getColorExpression()), null);
}
项目:jasperreports    文件:ColorFieldHandler.java   
@Override
public Object convertUponGet(Object value)
{
    if (value == null)
    {
        return null;
    }
    return "#" + JRColorUtil.getColorHexa((Color)value);
}
项目:jasperreports    文件:ColorFieldHandler.java   
@Override
public Object convertUponSet(Object value)
{
    if (value == null)
    {
        return null;
    }
    return JRColorUtil.getColor((String)value, null);
}
项目:jasperreports    文件:AbstractIntervalMarkerCustomizer.java   
protected IntervalMarker createMarker()
{
    Double startValue = getDoubleProperty(PROPERTY_START_VALUE);
    Double endValue = getDoubleProperty(PROPERTY_END_VALUE);

    if (
        startValue == null 
        || endValue == null
        )
    {
        return null;
    }

    IntervalMarker marker = new IntervalMarker(startValue, endValue);

    configureMarker(marker);

    Float strokeWidth = getFloatProperty(PROPERTY_STROKE_WIDTH);
    if (
        strokeWidth != null
        && strokeWidth > 0
        ) 
    {
        BasicStroke basicStroke = getStroke(strokeWidth);

        marker.setOutlineStroke(basicStroke);

        Color outlineColor = JRColorUtil.getColor(getProperty(PROPERTY_OUTLINE_COLOR), null);
        if (outlineColor != null)
        {
            marker.setOutlinePaint(outlineColor);
        }
    }

    return marker;
}
项目:jasperreports    文件:JRThermometerPlotFactory.java   
@Override
public Object createObject(Attributes atts) throws JRException
{
    JRChart chart = (JRChart)digester.peek();
    JRDesignThermometerPlot thermometerPlot = (JRDesignThermometerPlot)chart.getPlot();

    String location = atts.getValue(ATTRIBUTE_valueLocation);
    ValueLocationEnum loc = ValueLocationEnum.getByName(atts.getValue(ATTRIBUTE_valueLocation));
    if (loc == null)
    {
        throw 
            new JRException(
                EXCEPTION_MESSAGE_KEY_INVALID_VALUE_LOCATION,
                new Object[]{location});
    }
    else
    {
        thermometerPlot.setValueLocation(loc);
    }

    String mercuryColor = atts.getValue(ATTRIBUTE_mercuryColor);
    if (mercuryColor != null && mercuryColor.length() > 0)
    {
        thermometerPlot.setMercuryColor(JRColorUtil.getColor(mercuryColor, null));
    }

    return thermometerPlot;
}
项目:jasperreports    文件:JRChartFactory.java   
@Override
public Object createObject(Attributes atts)
{
    JRDesignChart chart = (JRDesignChart) digester.peek();

    Color color = JRColorUtil.getColor(atts.getValue(JRXmlConstants.ATTRIBUTE_color), Color.black);
    if (color != null)
    {
        chart.setSubtitleColor(color);
    }

    return chart;
}
项目:jasperreports    文件:JRChartPlotFactory.java   
@Override
@SuppressWarnings("deprecation")
public Object createObject(Attributes atts)
{
    JRChartPlot plot = (JRChartPlot) digester.peek();

    Color color = JRColorUtil.getColor(atts.getValue(JRXmlConstants.ATTRIBUTE_backcolor), Color.black);
    if (color != null)
    {
        plot.setBackcolor(color);
    }

    PlotOrientationEnum orientation = PlotOrientationEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_orientation));
    if (orientation != null)
    {
        plot.setOrientation(orientation);
    }
    String foregroundAlpha = atts.getValue(JRXmlConstants.ATTRIBUTE_foregroundAlpha);
    if (foregroundAlpha != null && foregroundAlpha.length() > 0)
    {
        plot.setForegroundAlpha(Float.valueOf(foregroundAlpha));
    }
    String backgroundAlpha = atts.getValue(JRXmlConstants.ATTRIBUTE_backgroundAlpha);
    if (backgroundAlpha != null && backgroundAlpha.length() > 0)
    {
        plot.setBackgroundAlpha(Float.valueOf(backgroundAlpha));
    }
    String labelRotation = atts.getValue(JRXmlConstants.ATTRIBUTE_labelRotation);
    if (labelRotation != null && labelRotation.length() > 0)
    {
        plot.setLabelRotation(Double.valueOf(labelRotation));
    }
    return plot;
}
项目:jasperreports    文件:TableStyle.java   
@Override
    public void write(String tableStyleName) throws IOException
    {
        styleWriter.write(" <style:style style:name=\"" + tableStyleName + "\"");
        if (!isFrame)
        {
            styleWriter.write(" style:master-page-name=\"master_" + pageFormatIndex +"\"");
        }
        styleWriter.write(" style:family=\"table\">\n");
        styleWriter.write("   <style:table-properties");        
        styleWriter.write(" table:align=\"left\" style:width=\"" + LengthUtil.inchFloor4Dec(width) + "in\"");
        if (isPageBreak)
        {
            styleWriter.write(" fo:break-before=\"page\"");
        }
        if (tabColor != null)
        {
            styleWriter.write(" tableooo:tab-color=\"#" + JRColorUtil.getColorHexa(tabColor) + "\"");
        }
//      FIXMEODT
//      if (tableWidth != null)
//      {
//          styleWriter.write(" style:width=\""+ tableWidth +"in\"");
//      }
//      if (align != null)
//      {
//          styleWriter.write(" table:align=\""+ align +"\"");
//      }
//      if (margin != null)
//      {
//          styleWriter.write(" fo:margin=\""+ margin +"\"");
//      }
//      if (backGroundColor != null)
//      {
//          styleWriter.write(" fo:background-color=\""+ backGroundColor +"\"");
//      }
        styleWriter.write("/>\n");
        styleWriter.write(" </style:style>\n");
        styleWriter.flush();
    }
项目:jasperreports    文件:FrameStyle.java   
/**
 *
 */
public FrameStyle(WriterHelper styleWriter, JRPrintElement element)
{
    super(styleWriter);

    if (element.getModeValue() == ModeEnum.OPAQUE)
    {
        fill = "solid";
        backcolor = JRColorUtil.getColorHexa(element.getBackcolor());
    }
    else
    {
        fill = "none";
    }
}
项目:jasperreports    文件:BorderStyle.java   
/**
 *
 */
private void appendBorder(JRPen pen, int side)
{
    double width = pen.getLineWidth().doubleValue();
    String style = null;

    if (width > 0f)
    {
        switch (pen.getLineStyleValue())//FIXMEBORDER is this working? deal with double border too.
        {
            case DOTTED :
            {
                style = "dotted";
                break;
            }
            case DASHED :
            {
                style = "dashed";
                break;
            }
            case SOLID :
            default :
            {
                style = "solid";
                break;
            }
        }

        borderWidth[side] = String.valueOf(LengthUtil.inchFloor4Dec(width));
    }
    else
    {
        style = "none";
    }

    borderStyle[side] = style;
    borderColor[side] = JRColorUtil.getColorHexa(pen.getLineColor());
}
项目:jasperreports    文件:CellStyle.java   
/**
 *
 */
public CellStyle(WriterHelper styleWriter, JRExporterGridCell gridCell, boolean shrinkToFit, boolean wrapText)
{
    super(styleWriter);

    JRPrintElement element = gridCell.getElement();

    if (element != null && element.getModeValue() == ModeEnum.OPAQUE)
    {
        //fill = "solid";
        backcolor = JRColorUtil.getColorHexa(element.getBackcolor());
    }
    else
    {
        //fill = "none";
        if (gridCell.getBackcolor() != null)
        {
            backcolor = JRColorUtil.getColorHexa(gridCell.getBackcolor());
        }
    }

    RotationEnum rotation = element instanceof JRPrintText ? ((JRPrintText)element).getRotationValue() : RotationEnum.NONE;
    VerticalTextAlignEnum vAlign = VerticalTextAlignEnum.TOP;
    HorizontalTextAlignEnum hAlign = HorizontalTextAlignEnum.LEFT;

    JRTextAlignment alignment = element instanceof JRTextAlignment ? (JRTextAlignment)element : null;
    if (alignment != null)
    {
        vAlign = alignment.getVerticalTextAlign();
        hAlign = alignment.getHorizontalTextAlign();
    }

    horizontalAlignment = ParagraphStyle.getHorizontalAlignment(hAlign, vAlign, rotation);
    verticalAlignment = ParagraphStyle.getVerticalAlignment(hAlign, vAlign, rotation);
    this.shrinkToFit = shrinkToFit;
    this.wrapText = wrapText;
    setBox(gridCell.getBox());
}
项目:jasperreports    文件:HtmlExporter.java   
protected Color appendBackcolorStyle(TableCell cell, StringBuilder styleBuffer)
{
    Color cellBackcolor = cell.getBackcolor();
    if (cellBackcolor != null && !matchesBackcolor(cellBackcolor))
    {
        styleBuffer.append("background-color: ");
        styleBuffer.append(JRColorUtil.getCssColor(cellBackcolor));
        styleBuffer.append("; ");

        return cellBackcolor;
    }

    return null;
}
项目:jasperreports    文件:DocxCellHelper.java   
/**
 *
 */
private void exportBackcolor(ModeEnum mode, Color backcolor)
{
    if (mode == ModeEnum.OPAQUE && backcolor != null)
    {
        write("      <w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"" + JRColorUtil.getColorHexa(backcolor) + "\" />\n");
    }
}
项目:jasperreports    文件:DocxBorderHelper.java   
/**
 *
 */
private void exportBorder(DocxBorderInfo info, int side)
{
    if (info.borderWidth[side] != null)
    {
        write("<w:" + DocxBorderInfo.BORDER[side] +" w:val=\"" + info.borderStyle[side] + "\" w:sz=\"" + info.borderWidth[side] + "\" w:space=\"0\"");
        if (info.borderColor[side] != null)//FIXMEDOCX check this; use default color?
        {
            write(" w:color=\"" + JRColorUtil.getColorHexa(info.borderColor[side]) + "\"");
        }
        write(" />\n");
    }
}
项目:jasperreports    文件:JRCellContentsFactory.java   
@Override
public Object createObject(Attributes attributes)
{
    JRDesignCellContents cell = new JRDesignCellContents();

    String backcolor = attributes.getValue(ATTRIBUTE_backcolor);
    if (backcolor != null && backcolor.length() > 0)
    {
        cell.setBackcolor(JRColorUtil.getColor(backcolor, null));
    }

    ModeEnum mode = ModeEnum.getByName(attributes.getValue(ATTRIBUTE_mode));
    if (mode != null)
    {
        cell.setMode(mode);
    }

    String styleName = attributes.getValue(ATTRIBUTE_style);
    if (styleName != null)
    {
        JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2);
        Map<String, JRStyle> stylesMap = jasperDesign.getStylesMap();

        if (stylesMap.containsKey(styleName))
        {
            JRStyle style = stylesMap.get(styleName);
            cell.setStyle(style);
        }
        else
        {
            cell.setStyleNameReference(styleName);
        }
    }

    return cell;
}
项目:jasperreports    文件:ChartSettingsXmlFactory.java   
@Override
public Object createObject(Attributes atts)
{
    StandardChartSettings chartSettings = new StandardChartSettings();

    String isShowLegend = atts.getValue(JRXmlConstants.ATTRIBUTE_isShowLegend);
    if (isShowLegend != null && isShowLegend.length() > 0)
    {
        chartSettings.setShowLegend(Boolean.valueOf(isShowLegend));
    }

    Color backcolor = JRColorUtil.getColor(atts.getValue(JRXmlConstants.ATTRIBUTE_backcolor), null);
    if (backcolor != null)
    {
        chartSettings.setBackcolor(backcolor);
    }

    chartSettings.setLinkType(atts.getValue(JRXmlConstants.ATTRIBUTE_hyperlinkType));
    chartSettings.setLinkTarget(atts.getValue(JRXmlConstants.ATTRIBUTE_hyperlinkTarget));

    String bookmarkLevelAttr = atts.getValue(JRXmlConstants.ATTRIBUTE_bookmarkLevel);
    if (bookmarkLevelAttr != null)
    {
        chartSettings.setBookmarkLevel(Integer.parseInt(bookmarkLevelAttr));
    }

    chartSettings.setCustomizerClass(atts.getValue(JRXmlConstants.ATTRIBUTE_customizerClass));
    chartSettings.setRenderType(atts.getValue(JRXmlConstants.ATTRIBUTE_renderType));

    return chartSettings;
}
项目:jasperreports    文件:ChartSettingsXmlFactory.java   
@Override
public Object createObject(Attributes atts)
{
    StandardChartSettings chartSettings = (StandardChartSettings) digester.peek();

    Color color = JRColorUtil.getColor(atts.getValue(JRXmlConstants.ATTRIBUTE_color), Color.black);
    if (color != null)
    {
        chartSettings.setSubtitleColor(color);
    }

    return chartSettings;
}
项目:jasperreports    文件:FillStyleItem.java   
@Override
public Object getEvaluatedValue(ItemProperty property, JRFillExpressionEvaluator evaluator, byte evaluation) throws JRException
{
    Object result = super.getEvaluatedValue(property, evaluator, evaluation);
    return PROPERTY_COLOR.equals(property.getName()) 
            ? JRColorUtil.getColorHexa(JRColorUtil.getColor((String)result, ColorEnum.RED.getColor()))
            : result;
}
项目:jasperreports    文件:FillPlaceItem.java   
@Override
public Object getEvaluatedValue(ItemProperty property, JRFillExpressionEvaluator evaluator, byte evaluation) throws JRException
{
    Object result = super.getEvaluatedValue(property, evaluator, evaluation);
    return MapComponent.ITEM_PROPERTY_address.equals(property.getName())
        ? getCoords((String)result)
        : (PROPERTY_COLOR.equals(property.getName()) 
            ? JRColorUtil.getColorHexa(JRColorUtil.getColor((String)result, ColorEnum.RED.getColor()))
            : result);
}
项目: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());
    }
}
项目:jasperreports    文件:SortComponentSymbolFactory.java   
@Override
public Object createObject(Attributes atts) throws JRException
{
    SortComponent sortComponent = (SortComponent)digester.peek();

    // Set the text color
    String attrValue = atts.getValue(SortComponent.PROPERTY_HANDLER_COLOR);
    if (attrValue != null && attrValue.length() > 0)
    {
        Color color = JRColorUtil.getColor(attrValue, null);
        sortComponent.setHandlerColor(color);
    }

    sortComponent.setSortFieldName(atts.getValue(SortComponent.PROPERTY_COLUMN_NAME));

    SortFieldTypeEnum fieldType = SortFieldTypeEnum.getByName(atts.getValue(SortComponent.PROPERTY_COLUMN_TYPE));
    if (fieldType != null)
    {
        sortComponent.setSortFieldType(fieldType);
    }

    HorizontalImageAlignEnum hAlign = HorizontalImageAlignEnum.getByName(atts.getValue(SortComponent.PROPERTY_HANDLER_HORIZONTAL_ALIGN));
    if (hAlign != null)
    {
        sortComponent.setHandlerHorizontalImageAlign(hAlign);
    }

    VerticalImageAlignEnum vAlign = VerticalImageAlignEnum.getByName(atts.getValue(SortComponent.PROPERTY_HANDLER_VERTICAL_ALIGN));
    if (vAlign != null)
    {
        sortComponent.setHandlerVerticalImageAlign(vAlign);
    }

    return sortComponent;
}
项目:ireport-fork    文件:PaintProviderPropertyEditor.java   
/** sets new value */
@Override
public String getAsText() 
{
    PaintProvider paintProvider = getValue() instanceof PaintProvider ? (PaintProvider)getValue() : null;
    if (paintProvider == null || paintProvider.getPaint() == null)
    {
        return "";
    }
    else
    {
        Paint paint = paintProvider.getPaint();

        GradientPaint gradientPaint = paint instanceof GradientPaint ? (GradientPaint)paint : null;
        if (gradientPaint != null)
        {
            return 
                "#" + JRColorUtil.getColorHexa(gradientPaint.getColor1())
                + " #" + JRColorUtil.getColorHexa(gradientPaint.getColor2());
        }
        else
        {
            return 
                "#" + JRColorUtil.getColorHexa((Color)paint);
        }
    }
}
项目:dynamicreports-jasper    文件:OpenFlashChartHtmlHandler.java   
@Override
public String getHtmlFragment(JRHtmlExporterContext exporterContext, JRGenericPrintElement element) {
    String divID = "ofc" + System.identityHashCode(element);
    int width = element.getWidth();
    int height = element.getHeight();
    Color backcolor = element.getBackcolor();
    String chartData = ((ChartGenerator) element.getParameterValue(ChartGenerator.PARAMETER_CHART_GENERATOR)).generateChart();
    String chartEncodedData = JRStringUtil.htmlEncode(chartData);

    StringBuffer result = new StringBuffer();
    result.append("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" ");
    result.append("width=\"" + width + "\" ");
    result.append("height=\"" + height + "\" ");
    result.append("id=\"" + divID + "\" ");
    result.append("align=\"middle\">");
    result.append("<param name=\"allowScriptAccess\" value=\"sameDomain\" /> ");
    result.append("<param name=\"movie\" value=\"");
    result.append(getSwfLocation());
    result.append("?width=" + width);
    result.append("&height=" + height);
    result.append("&inline_data=" + chartEncodedData);
    result.append("\" /> ");
    result.append("<param name=\"quality\" value=\"high\" />");
    result.append("<param name=\"bgcolor\" value=\"#" + JRColorUtil.getColorHexa(backcolor) + "\" /> ");
    result.append("<embed src=\"");
    result.append(getSwfLocation());
    result.append("?width=" + width);
    result.append("&height=" + height);
    result.append("&inline_data=" + chartEncodedData);
    result.append("\" quality=\"high\" ");
    result.append("bgcolor=\"#" + JRColorUtil.getColorHexa(backcolor) + "\" ");
    result.append("width=\"" + width + "\" ");
    result.append("height=\"" + height + "\" ");
    result.append("name=\"open-flash-chart\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /> </object> ");

    return result.toString();
}
项目:jasperreports-wms-component    文件:WmsMapElementHtmlHandler.java   
@Override
public String getHtmlFragment(JRHtmlExporterContext context,
    JRGenericPrintElement element) {

  Map<String, Object> contextMap = new HashMap<String, Object>();
  contextMap.put("mapCanvasId", "map_canvas_" + element.hashCode());

  if (context.getExporter() instanceof JRXhtmlExporter) {
    contextMap.put("xhtml", "xhtml");
    JRXhtmlExporter xhtmlExporter = (JRXhtmlExporter) context.getExporter();
    contextMap.put("elementX", xhtmlExporter.toSizeUnit(element.getX()));
    contextMap.put("elementY", xhtmlExporter.toSizeUnit(element.getY()));
  } else {
    JRHtmlExporter htmlExporter = (JRHtmlExporter) context.getExporter();
    contextMap.put("elementX", htmlExporter.toSizeUnit(element.getX()));
    contextMap.put("elementY", htmlExporter.toSizeUnit(element.getY()));
  }
  contextMap.put("elementId", element.getKey());
  contextMap.put("elementWidth", element.getWidth());
  contextMap.put("elementHeight", element.getHeight());

  if (element.getModeValue() == ModeEnum.OPAQUE) {
    contextMap.put("backgroundColor",
        JRColorUtil.getColorHexa(element.getBackcolor()));
  }
  WmsRequestBuilder requestBuilder =
      WmsMapElementImageProvider.mapRequestBuilder(element);
  try {
    contextMap.put("wmsMapUrl", requestBuilder.toMapUrl());
  } catch (MalformedURLException e) {
    throw new RuntimeException("Unable to build WMS map service url", e);
  }

  return VelocityUtil.processTemplate(MAP_ELEMENT_HTML_TEMPLATE, contextMap);
}
项目:jasperreports    文件:AbstractMarkerCustomizer.java   
protected void configureMarker(Marker marker)
{
    String label = getProperty(PROPERTY_LABEL);
    if (label != null && label.length() > 0)
    {
        marker.setLabel(label);
    }

    RectangleAnchorEnum labelAnchor = RectangleAnchorEnum.getByName(getProperty(PROPERTY_LABEL_ANCHOR));
    if (labelAnchor != null)
    {
        marker.setLabelAnchor(labelAnchor.getRectangleAnchor());
    }

    Double offsetTop = getDoubleProperty(PROPERTY_LABEL_OFFSET_TOP);
    Double offsetLeft = getDoubleProperty(PROPERTY_LABEL_OFFSET_LEFT);
    Double offsetBottom = getDoubleProperty(PROPERTY_LABEL_OFFSET_BOTTOM);
    Double offsetRight = getDoubleProperty(PROPERTY_LABEL_OFFSET_RIGHT);
    if (
        offsetTop != null
        || offsetLeft != null
        || offsetBottom != null
        || offsetRight != null
        )
    {
        RectangleInsets currentOffset = marker.getLabelOffset();
        marker.setLabelOffset(
            new RectangleInsets(
                offsetTop == null ? currentOffset.getTop() : offsetTop, 
                offsetLeft == null ? currentOffset.getLeft() : offsetLeft, 
                offsetBottom == null ? currentOffset.getBottom() : offsetBottom, 
                offsetRight == null ? currentOffset.getRight() : offsetRight
                )
            );
    }

    TextAnchorEnum labelTextAnchor = TextAnchorEnum.getByName(getProperty(PROPERTY_LABEL_TEXT_ANCHOR));
    if (labelTextAnchor != null) 
    {
        marker.setLabelTextAnchor(labelTextAnchor.getTextAnchor());
    }

    Color color = JRColorUtil.getColor(getProperty(PROPERTY_COLOR), null);
    if (color != null)
    {
        marker.setPaint(color);
    }

    Float alpha = getFloatProperty(PROPERTY_ALPHA);
    if (alpha != null)
    {
        marker.setAlpha(alpha);
    }
}
项目:jasperreports    文件:ChartHtmlHandler.java   
public String getHtmlFragment(JRHtmlExporterContext exporterContext, JRGenericPrintElement element)
{
    String divID = "ofc" + System.identityHashCode(element);
    int width = element.getWidth();
    int height = element.getHeight();
    Color backcolor = element.getBackcolor();
    String swfLocation = "openflashchart/open-flash-chart.swf";
    String chartData = (String) element.getParameterValue(PARAMETER_CHART_DATA);
    String chartEncodedData = JRStringUtil.htmlEncode(chartData);

    return 
        "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"" +
            width +
            "\" height=\"" +
            height +
            "\" id=\"" +
            divID +
            "\" align=\"middle\"><param name=\"allowScriptAccess\" value=\"sameDomain\" /> <param name=\"movie\" value=\"" +
            swfLocation +
            "?width=" +
            width +
            "&height=" +
            height +
            "&inline_data=" +
            chartEncodedData +
            "\" /> <param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"" +
            "#" + JRColorUtil.getColorHexa(backcolor) +
            "\" /> <embed src=\"" +
            swfLocation +
            "?width=" +
            width +
            "&height=" +
            height +
            "&inline_data=" +
            chartEncodedData +
            "\" quality=\"high\" bgcolor=\"" +
            "#" + JRColorUtil.getColorHexa(backcolor) +
            "\" width=\"" +
            width +
            "\" height=\"" +
            height +
            "\" name=\"open-flash-chart\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /> </object> ";
}
项目:jasperreports    文件:JRMeterPlotFactory.java   
@Override
public Object createObject(Attributes atts) throws JRException
{
    JRChart chart = (JRChart)digester.peek();
    JRDesignMeterPlot meterPlot = (JRDesignMeterPlot)chart.getPlot();

    MeterShapeEnum shape = MeterShapeEnum.getByName(atts.getValue(ATTRIBUTE_shape));
    if (shape != null)
    {
        meterPlot.setShape(shape);
    }

    String angle = atts.getValue(ATTRIBUTE_angle);
    if (angle != null && angle.length() > 0)
    {
        meterPlot.setMeterAngle(Integer.valueOf(angle));
    }

    String units = atts.getValue(ATTRIBUTE_units);
    if (units != null && units.length() > 0)
    {
        meterPlot.setUnits(units);
    }

    String tickInterval = atts.getValue(ATTRIBUTE_tickInterval);
    if (tickInterval != null && tickInterval.length() > 0)
    {
        meterPlot.setTickInterval(Double.valueOf(tickInterval));
    }

    String meterColor = atts.getValue(ATTRIBUTE_meterColor);
    if (meterColor != null && meterColor.length() > 0)
    {
        meterPlot.setMeterBackgroundColor(JRColorUtil.getColor(meterColor, null));
    }

    String needleColor = atts.getValue(ATTRIBUTE_needleColor);
    if (needleColor != null && needleColor.length() > 0)
    {
        meterPlot.setNeedleColor(JRColorUtil.getColor(needleColor, null));
    }

    String tickColor = atts.getValue(ATTRIBUTE_tickColor);
    if (tickColor != null && tickColor.length() > 0)
    {
        meterPlot.setTickColor(JRColorUtil.getColor(tickColor, null));
    }

    String tickCount = atts.getValue(ATTRIBUTE_tickCount);
    if (tickCount != null && tickCount.length() > 0)
    {
        meterPlot.setTickCount(Integer.valueOf(tickCount));
    }

    return meterPlot;
}