void StressMinimization::minimizeStress( GraphAttributes& GA, NodeArray<NodeArray<double> >& shortestPathMatrix, NodeArray<NodeArray<double> >& weightMatrix) { const Graph& G = GA.constGraph(); int numberOfPerformedIterations = 0; double prevStress = numeric_limits<double>::max(); double curStress = numeric_limits<double>::max(); if (m_terminationCriterion == STRESS) { curStress = calcStress(GA, shortestPathMatrix, weightMatrix); } NodeArray<double> newX; NodeArray<double> newY; NodeArray<double> newZ; if (m_terminationCriterion == POSITION_DIFFERENCE) { newX.init(G); newY.init(G); if (GA.has(GraphAttributes::threeD)) newZ.init(G); } do { if (m_terminationCriterion == POSITION_DIFFERENCE) { if (GA.has(GraphAttributes::threeD)) copyLayout(GA, newX, newY, newZ); else copyLayout(GA, newX, newY); } nextIteration(GA, shortestPathMatrix, weightMatrix); if (m_terminationCriterion == STRESS) { prevStress = curStress; curStress = calcStress(GA, shortestPathMatrix, weightMatrix); } } while (!finished(GA, ++numberOfPerformedIterations, newX, newY, prevStress, curStress)); Logger::slout() << "Iteration count:\t" << numberOfPerformedIterations << "\tStress:\t" << calcStress(GA, shortestPathMatrix, weightMatrix) << endl; }
int OzUIWidgetDrawTextLayout(struct OzUIWidget *widget, struct OzUITextLayoutConstraint *tlc, struct LineStyle *lineStyle, struct OzUITextLayout *layout) { struct OzUITextLayoutConstraint baseTLC; struct OzUITextLayout *baseLayout; int ret; memcpy(&baseTLC, tlc, sizeof(struct OzUITextLayoutConstraint)); baseTLC.originX += widget->rect.x; baseTLC.originY += widget->rect.y; baseTLC.rect.x += widget->rect.x; baseTLC.rect.y += widget->rect.y; baseLayout = copyLayout(layout); translateLayoutCoords(baseLayout, widget->rect.x, widget->rect.y); ret = OzUIWindowDrawTextLayout(widget->window, &widget->dirtyRect, &baseTLC, lineStyle, baseLayout); free(baseLayout); return ret; }