/** * Overrides method from UMLWidget */ UMLSceneSize PackageWidget::minimumSize() { if ( !m_pObject ) { return UMLWidget::minimumSize(); } const QFontMetrics &fm = getFontMetrics(FT_BOLD_ITALIC); const int fontHeight = fm.lineSpacing(); int lines = 1; int width = fm.width( m_pObject->name() ); int tempWidth = 0; if (!m_pObject->stereotype().isEmpty()) { tempWidth = fm.width(m_pObject->stereotype(true)); lines = 2; } if (tempWidth > width) width = tempWidth; width += PACKAGE_MARGIN * 2; if (width < 70) width = 70; // minumin width of 70 int height = (lines*fontHeight) + fontHeight + (PACKAGE_MARGIN * 2); return UMLSceneSize(width, height); }
UMLSceneSize CategoryWidget::minimumSize() { const UMLWidget::FontType ft = ( m_pObject->isAbstract() ? FT_BOLD_ITALIC : FT_BOLD ); const QFontMetrics &fm = UMLWidget::getFontMetrics(ft); const int fontHeight = fm.lineSpacing(); int radius = UC_RADIUS + fontHeight + UC_MARGIN; return UMLSceneSize(radius, radius); }
/** * Overrides method from UMLWidget. */ UMLSceneSize ActorWidget::minimumSize() { const QFontMetrics &fm = getFontMetrics(FT_NORMAL); const int fontHeight = fm.lineSpacing(); const int textWidth = fm.width(name()); int width = textWidth > A_WIDTH ? textWidth : A_WIDTH; int height = A_HEIGHT + fontHeight + A_MARGIN; width += A_MARGIN * 2; return UMLSceneSize(width, height); }
UMLSceneSize PreconditionWidget::minimumSize() { int width = 10, height = 10; const QFontMetrics &fm = getFontMetrics(FT_NORMAL); const int fontHeight = fm.lineSpacing(); const int textWidth = fm.width(name()) + 25; height = fontHeight; width = textWidth > PRECONDITION_WIDTH ? textWidth : PRECONDITION_WIDTH; height = height > PRECONDITION_HEIGHT ? height : PRECONDITION_HEIGHT; width += PRECONDITION_MARGIN * 2; height += PRECONDITION_MARGIN * 2; return UMLSceneSize(width, height); }
UMLSceneSize RegionWidget::minimumSize() { int width = 10, height = 10; const QFontMetrics &fm = getFontMetrics(FT_NORMAL); const int fontHeight = fm.lineSpacing(); int textWidth = fm.width(getName()); height = fontHeight; width = textWidth > REGION_WIDTH?textWidth:REGION_WIDTH; height = height > REGION_HEIGHT ? height : REGION_HEIGHT; width += REGION_MARGIN * 2; height += REGION_MARGIN * 2; return UMLSceneSize(width, height); }
UMLSceneSize ClassifierWidget::minimumSize() { if (!m_pObject) { return UMLWidget::minimumSize(); } if (classifier()->isInterface() && m_drawAsCircle) { return calculateAsCircleSize(); } const QFontMetrics &fm = getFontMetrics(UMLWidget::FT_NORMAL); const int fontHeight = fm.lineSpacing(); // width is the width of the longest 'word' int width = 0, height = 0; // consider stereotype if (m_showStereotype && !m_pObject->stereotype().isEmpty()) { height += fontHeight; // ... width const QFontMetrics &bfm = UMLWidget::getFontMetrics(UMLWidget::FT_BOLD); const int stereoWidth = bfm.size(0,m_pObject->stereotype(true)).width(); if (stereoWidth > width) width = stereoWidth; } // consider name height += fontHeight; // ... width QString displayedName; if (m_showPackage) displayedName = m_pObject->fullyQualifiedName(); else displayedName = m_pObject->name(); const UMLWidget::FontType nft = (m_pObject->isAbstract() ? FT_BOLD_ITALIC : FT_BOLD); const int nameWidth = UMLWidget::getFontMetrics(nft).size(0,displayedName).width(); if (nameWidth > width) width = nameWidth; // consider attributes const int numAtts = displayedAttributes(); if (numAtts == 0) { height += fontHeight / 2; // no atts, so just add a bit of space } else { height += fontHeight * numAtts; // calculate width of the attributes UMLClassifierListItemList list = classifier()->getFilteredList(UMLObject::ot_Attribute); foreach (UMLClassifierListItem *a , list ) { if (m_showPublicOnly && a->visibility() != Uml::Visibility::Public) continue; const int attWidth = fm.size(0,a->toString(m_ShowAttSigs)).width(); if (attWidth > width) width = attWidth; } } // consider operations const int numOps = displayedOperations(); if (numOps == 0) { height += fontHeight / 2; // no ops, so just add a bit of space } else { height += numOps * fontHeight; // ... width UMLOperationList list(classifier()->getOpList()); foreach (UMLOperation* op , list) { if (m_showPublicOnly && op->visibility() != Uml::Visibility::Public) continue; const QString displayedOp = op->toString(m_ShowOpSigs); UMLWidget::FontType oft; oft = (op->isAbstract() ? UMLWidget::FT_ITALIC : UMLWidget::FT_NORMAL); const int w = UMLWidget::getFontMetrics(oft).size(0,displayedOp).width(); if (w > width) width = w; } } // consider template box _as last_ ! QSize templatesBoxSize = calculateTemplatesBoxSize(); if (templatesBoxSize.width() != 0) { // add width to largest 'word' width += templatesBoxSize.width() / 2; } if (templatesBoxSize.height() != 0) { height += templatesBoxSize.height() - MARGIN; } // allow for height margin if (!m_showOperations && !m_showAttributes && !m_showStereotype) { height += MARGIN * 2; } // allow for width margin width += MARGIN * 2; return UMLSceneSize(width, height); }