bool SVGPaintServerGradient::setup(QPainter* painter, QPainterPath* painterPath, const RenderObject* object,
                                   SVGPaintTargetType type, bool isPaintingText) const
{
    Q_UNUSED(isPaintingText);
    kDebug() << "!!!!!!!" << endl;
    m_ownerElement->buildGradient();

    /*QPainter* painter(context ? context->platformContext() : 0);
    Q_ASSERT(painter);*/

    /*QPainterPath* path(context ? context->currentPath() : 0);
    Q_ASSERT(path);*/

    RenderStyle* renderStyle = object->style();

    QGradient gradient = setupGradient(painter, painterPath, object);

    painter->setPen(Qt::NoPen);
    painter->setBrush(Qt::NoBrush);

    if (spreadMethod() == SPREADMETHOD_REPEAT)
        gradient.setSpread(QGradient::RepeatSpread);
    else if (spreadMethod() == SPREADMETHOD_REFLECT)
        gradient.setSpread(QGradient::ReflectSpread);
    else
        gradient.setSpread(QGradient::PadSpread);    
    double opacity = 1.0;

    kDebug() << "type: " << type << (type & ApplyToFillTargetType) << endl;
    if ((type & ApplyToFillTargetType) && renderStyle->svgStyle()->hasFill()) {
        fillColorArray(gradient, gradientStops(), opacity);

        QBrush brush(gradient);
        brush.setMatrix(gradientTransform());

        painter->setBrush(brush);
        /* FIXME khtml context->setFillRule(renderStyle->svgStyle()->fillRule());*/
    }

    if ((type & ApplyToStrokeTargetType) && renderStyle->svgStyle()->hasStroke()) {
        fillColorArray(gradient, gradientStops(), opacity);

        QPen pen;
        QBrush brush(gradient);
        brush.setMatrix(gradientTransform());

        setPenProperties(object, renderStyle, pen);
        pen.setBrush(brush);

        painter->setPen(pen);
    }

    return true;
}
Beispiel #2
0
bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject* object,
                                   SVGPaintTargetType type, bool isPaintingText) const
{
    m_ownerElement->buildGradient();

    QPainter* painter(context ? context->platformContext() : 0);
    Q_ASSERT(painter);

    QPainterPath* path(context ? context->currentPath() : 0);
    Q_ASSERT(path);

    const SVGRenderStyle* svgStyle = object->style()->svgStyle();
    RenderStyle* style = object->style();

    QGradient gradient = setupGradient(context, object);

    painter->setPen(Qt::NoPen);
    painter->setBrush(Qt::NoBrush);

    if (spreadMethod() == SpreadMethodRepeat)
        gradient.setSpread(QGradient::RepeatSpread);
    else if (spreadMethod() == SpreadMethodReflect)
        gradient.setSpread(QGradient::ReflectSpread);
    else
        gradient.setSpread(QGradient::PadSpread);    
    double opacity = 1.0;

    if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) {
        fillColorArray(gradient, gradientStops(), opacity);

        QBrush brush(gradient);
        brush.setMatrix(gradientTransform());

        painter->setBrush(brush);
        context->setFillRule(svgStyle->fillRule());
    }

    if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) {
        fillColorArray(gradient, gradientStops(), opacity);

        QPen pen;
        QBrush brush(gradient);
        brush.setMatrix(gradientTransform());
        pen.setBrush(brush);
        painter->setPen(pen);

        applyStrokeStyleToContext(context, style, object);
    }

    return true;
}
ColorManager::ColorManager(vector < Feature> *fList, int colorCount)
{
    aktColormanager = this;
    colorArray = new QList <Color*>;
    defaultGrey1 = new Color(QColor(220, 220, 220, 255)); //silver
    defaultGrey2 = new Color(QColor(180, 180, 180, 255)); //grey
    white = new Color(QColor(255, 255, 255, 255));
    maxColorCount = 200;//muss noch geändert werden
    dummyToDoMod2 = 0;
    featureList = fList;
    FCPList = new vector <FeatureColorPair>();
    fillColorArray(colorCount);
    initializeFCPList();
}