/* [AS] Wildcard pattern matching */ Boolean HasPattern (const char * text, const char * pattern) { while( *pattern != '\0' ) { if( *pattern == '*' ) { while( *pattern == '*' ) { pattern++; } if( *pattern == '\0' ) { return TRUE; } while( *text != '\0' ) { if( HasPattern( text, pattern ) ) { return TRUE; } text++; } } else if( (*pattern == *text) || ((*pattern == '?') && (*text != '\0')) ) { pattern++; text++; continue; } return FALSE; } return TRUE; }
Boolean SearchPattern (const char * text, const char * pattern) { Boolean result = TRUE; if( pattern != NULL && *pattern != '\0' ) { if( *pattern == '*' ) { result = HasPattern( text, pattern ); } else { result = FALSE; while( *text != '\0' ) { if( HasPattern( text, pattern ) ) { result = TRUE; break; } text++; } } } return result; }
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); } } }