void JSummation::Render ( const JExprRenderer& renderer, const JExprRectList& rectList ) const { // find ourselves in the list JIndex ourIndex; const JBoolean found = rectList.FindFunction(this, &ourIndex); assert( found ); const JRect ourRect = rectList.GetRect(ourIndex); const JCoordinate ourMidline = rectList.GetMidline(ourIndex); const JSize fontSize = rectList.GetFontSize(ourIndex); // draw ourselves JCoordinate h = ourRect.left; const JSize spaceWidth = renderer.GetStringWidth(fontSize, " "); const JSize argCount = GetArgCount(); for (JIndex i=1; i<=argCount; i++) { const JFunction* f = this; const JFunction* arg = GetArg(i); if (arg->GetType() == kJNegationType) { renderer.DrawString(h, ourMidline, fontSize, JPGetSubtractionString()); f = arg; const JNegation* neg = dynamic_cast<const JNegation*>(arg); assert( neg != NULL ); arg = neg->GetArg(); } else if (i > 1) { renderer.DrawString(h, ourMidline, fontSize, JPGetAdditionString()); } arg->Render(renderer, rectList); JIndex argIndex; const JBoolean found = rectList.FindFunction(arg, &argIndex); assert( found ); const JRect argRect = rectList.GetRect(argIndex); h = argRect.right; if (ParenthesizeArgForRender(*f, *arg)) { renderer.DrawParentheses(argRect); h += renderer.GetParenthesisWidth(argRect.height()); } h += spaceWidth; } }
void JFunctionWithVar::DrawString ( const JExprRenderer& renderer, const JCoordinate left, const JCoordinate midline, const JSize fontSize, const JString& str ) const { JCoordinate x = left; const JCharacter* greekPrefix = JPGetGreekCharPrefixString(); const JSize greekPrefixLength = JPGetGreekCharPrefixLength(); JString s = str; JIndex greekIndex; while (s.LocateSubstring(greekPrefix, &greekIndex) && greekIndex < s.GetLength() - greekPrefixLength + 1) { if (greekIndex > 1) { const JString s1 = s.GetSubstring(1, greekIndex-1); renderer.DrawString(x, midline, fontSize, s1); x += renderer.GetStringWidth(fontSize, s1); } const JCharacter c = s.GetCharacter(greekIndex + greekPrefixLength); renderer.DrawGreekCharacter(x, midline, fontSize, c); x += renderer.GetGreekCharWidth(fontSize, c); s.RemoveSubstring(1, greekIndex + greekPrefixLength); } if (!s.IsEmpty()) { renderer.DrawString(x, midline, fontSize, s); } }
void JLogB::Render ( const JExprRenderer& renderer, const JExprRectList& rectList ) const { // find ourselves in the list JIndex ourIndex; const JBoolean found = rectList.FindFunction(this, &ourIndex); assert( found ); const JRect ourRect = rectList.GetRect(ourIndex); const JCoordinate ourMidline = rectList.GetMidline(ourIndex); const JSize fontSize = rectList.GetFontSize(ourIndex); // draw ourselves const JCharacter* name = GetName(); const JSize nameLength = strlen(name); assert( nameLength > 1 ); assert( name[ nameLength-1 ] == '(' ); const JString fnName = JString(name, nameLength-1); renderer.DrawString(ourRect.left, ourMidline, fontSize, fnName); // draw the base (GetArg1())->Render(renderer, rectList); // draw the argument const JFunction* arg = GetArg2(); arg->Render(renderer, rectList); JIndex argIndex; const JBoolean foundArg = rectList.FindFunction(arg, &argIndex); assert( foundArg ); renderer.DrawParentheses(rectList.GetRect(argIndex)); }
void JFunction::Render ( const JExprRenderer& renderer, const JExprRectList& rectList ) const { // find ourselves in the list JIndex ourIndex; const JBoolean found = rectList.FindFunction(this, &ourIndex); assert( found ); const JRect ourRect = rectList.GetRect(ourIndex); const JCoordinate ourMidline = rectList.GetMidline(ourIndex); const JSize fontSize = rectList.GetFontSize(ourIndex); // display the output of Print const JString text = Print(); renderer.DrawString(ourRect.left, ourMidline, fontSize, text); }