long JKLRand::UniformLong ( const long lim1, const long lim2 ) const { long max,min; if (lim1 <= lim2) { min = lim1; max = lim2; } else { min = lim2; max = lim1; } return JLFloor(UniformSemiOpenProb()*(max-min + 1) + min); }
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); } } }