void JNamedConstant::Render ( const JExprRenderer& renderer, const JExprRectList& rectList ) const { if (strcmp(JPGetStdNamedConstName(itsNameIndex), JPGetPiString()) == 0) { // 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 the greek character for pi renderer.DrawGreekCharacter(ourRect.left, ourMidline, fontSize, kGreekPiChar); } else { JFunction::Render(renderer, rectList); } }
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::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 base name JString baseName, subscript; itsVariableList->GetVariableName(itsVariableIndex, &baseName, &subscript); DrawString(renderer, ourRect.left, ourMidline, fontSize, baseName); // draw subscript if (!subscript.IsEmpty()) { const JCoordinate subLeft = ourRect.left + GetStringWidth(renderer, fontSize, baseName); const JSize subFontSize = renderer.GetSuperSubFontSize(fontSize); const JSize subHeight = renderer.GetLineHeight(subFontSize); DrawString(renderer, subLeft, ourMidline + subHeight/2, subFontSize, subscript); } // draw our array index if (itsArrayIndex != NULL) { itsArrayIndex->Render(renderer, rectList); JIndex argIndex; const JBoolean found = rectList.FindFunction(itsArrayIndex, &argIndex); assert( found ); renderer.DrawSquareBrackets(rectList.GetRect(argIndex)); } }
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); }
void JParallel::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 JSize spaceWidth = renderer.GetStringWidth(fontSize, " "); const JSize barWidth = renderer.GetVertBarWidth(); const JSize lineHeight = renderer.GetLineHeight(fontSize); JSize maxBarLength; if (((JSize) ourRect.height()) > lineHeight) { maxBarLength = JLFloor(ourRect.height()/2.0); } else { maxBarLength = ourRect.height(); } JSize barLength; if (ourMidline > ourRect.ycenter()) { barLength = 2*(ourRect.bottom - ourMidline); } else { barLength = 2*(ourMidline - ourRect.top); } if (barLength > maxBarLength) { barLength = maxBarLength; } const JCoordinate barTop = ourMidline - barLength/2; const JSize argCount = GetArgCount(); for (JIndex i=1; i<=argCount; i++) { const JFunction* arg = GetArg(i); arg->Render(renderer, rectList); JIndex argIndex; const JBoolean found = rectList.FindFunction(arg, &argIndex); assert( found ); const JRect argRect = rectList.GetRect(argIndex); JCoordinate h = argRect.right + spaceWidth; if (ParenthesizeArgForRender(*this, *arg)) { renderer.DrawParentheses(argRect); h += renderer.GetParenthesisWidth(argRect.height()); } if (i < argCount) { renderer.DrawVertBar(h, barTop, barLength); renderer.DrawVertBar(h + barWidth, barTop, barLength); } } }