void MapPainterAgg::DrawFill(const Projection& projection, const MapParameter& parameter, const FillStyle& fillStyle, agg::path_storage& path) { if (fillStyle.GetFillColor().IsVisible()) { renderer_aa->color(agg::rgba(fillStyle.GetFillColor().GetR(), fillStyle.GetFillColor().GetG(), fillStyle.GetFillColor().GetB(), fillStyle.GetFillColor().GetA())); agg::render_scanlines(*rasterizer,*scanlineP8,*renderer_aa); } double borderWidth=projection.ConvertWidthToPixel(fillStyle.GetBorderWidth()); if (borderWidth>=parameter.GetLineMinWidthPixel()) { renderer_aa->color(agg::rgba(fillStyle.GetBorderColor().GetR(), fillStyle.GetBorderColor().GetG(), fillStyle.GetBorderColor().GetB(), fillStyle.GetBorderColor().GetA())); if (fillStyle.GetBorderDash().empty()) { agg::conv_stroke<agg::path_storage> stroke(path); stroke.width(borderWidth); stroke.line_cap(agg::round_cap); rasterizer->add_path(stroke); agg::render_scanlines(*rasterizer,*scanlineP8,*renderer_aa); } else { agg::conv_dash<agg::path_storage> dasher(path); agg::conv_stroke<agg::conv_dash<agg::path_storage> > stroke(dasher); stroke.width(borderWidth); stroke.line_cap(agg::butt_cap); for (size_t i=0; i<fillStyle.GetBorderDash().size(); i+=2) { dasher.add_dash(fillStyle.GetBorderDash()[i]*borderWidth, fillStyle.GetBorderDash()[i+1]*borderWidth); } rasterizer->add_path(stroke); agg::render_scanlines(*rasterizer,*scanlineP8,*renderer_aa); } } }
bool MapPainterCanvas::DrawMap(const StyleConfig& styleConfig, const Projection& projection, const MapParameter& parameter, const MapData& data, JNIEnv *env, jobject object) { mJniEnv=env; mPainterClass=env->FindClass("osm/scout/MapPainterCanvas"); mPainterObject=object; mMinimumLineWidth=parameter.GetLineMinWidthPixel()*25.4/parameter.GetDPI(); return Draw(styleConfig, projection, parameter, data); }
void MapPainterCanvas::DrawFillStyle(const Projection& projection, const MapParameter& parameter, const FillStyle& fill) { if (fill.HasPattern() && projection.GetMagnification()>=fill.GetPatternMinMag() && HasPattern(parameter,fill)) { jint patternId=fill.GetPatternId()-1; jmethodID methodId=mJniEnv->GetMethodID(mPainterClass, "drawPatternArea", "(I)V"); if (!methodId) return; mJniEnv->CallVoidMethod(mPainterObject, methodId, patternId); } else if (fill.GetFillColor().IsVisible()) { jint color=GetColorInt(fill.GetFillColor()); jmethodID methodId=mJniEnv->GetMethodID(mPainterClass, "drawFilledArea", "(I)V"); if (!methodId) return; mJniEnv->CallVoidMethod(mPainterObject, methodId, color); } // Draw border if (fill.GetBorderWidth()>0 && fill.GetBorderColor().IsVisible() && fill.GetBorderWidth()>=mMinimumLineWidth) { double borderWidth=ConvertWidthToPixel(parameter, fill.GetBorderWidth()); if (borderWidth>=parameter.GetLineMinWidthPixel()) { jfloatArray javaDash=NULL; float *dashArray=NULL; std::vector<double> dash=fill.GetBorderDash(); if (!dash.empty()) { javaDash=mJniEnv->NewFloatArray(dash.size()); dashArray=new float[dash.size()]; for(int i=0; i<dash.size(); i++) { dashArray[i]=dash[i]*borderWidth; } mJniEnv->SetFloatArrayRegion(javaDash, 0, dash.size(), dashArray); } jmethodID methodId=mJniEnv->GetMethodID(mPainterClass, "drawAreaBorder", "(IF[F)V"); jint javaColor=GetColorInt(fill.GetBorderColor()); mJniEnv->CallVoidMethod(mPainterObject, methodId, javaColor, (jfloat)borderWidth, javaDash); } } }