use of org.knime.base.node.viz.pie.datamodel.PieSubSectionDataModel in project knime-core by knime.
the class PieDrawingPane method paintContent.
/**
* {@inheritDoc}
*/
@Override
public synchronized void paintContent(final Graphics g) {
final Graphics2D g2 = (Graphics2D) g;
String msg = m_infoMsg;
if (m_vizModel == null) {
// if we have no bins and no info message display a no bars info
if (msg == null) {
msg = "No pie data available";
}
}
// check if we have to display an information message
if (msg != null) {
DrawingUtils.drawMessage(g2, INFO_MSG_FONT, msg, getBounds());
return;
}
final RenderingHints origHints = g2.getRenderingHints();
if (m_vizModel.drawAntialias()) {
// Enable antialiasing for shapes
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
} else {
// Disable antialiasing for shapes
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}
final Rectangle2D explodeArea = m_vizModel.getExplodedArea();
final Rectangle2D pieArea = m_vizModel.getPieArea();
final double labelLinkSize = m_vizModel.getLabelLinkSize();
final boolean explode = m_vizModel.explodeSelectedSections();
final boolean drawOutline = m_vizModel.drawSectionOutline();
// final AggregationMethod aggrMethod = m_vizModel.getAggregationMethod();
// final double totalValue = m_vizModel.getAbsAggregationValue();
final LabelDisplayPolicy labelPolicy = m_vizModel.getLabelDisplayPolicy();
final boolean showDetails = m_vizModel.showDetails();
for (final PieSectionDataModel section : m_vizModel.getSections2Draw()) {
if (!section.isPresentable()) {
// skip not presentable sections
continue;
}
// check if we should draw ...
if (showDetails && section.isSelected()) {
// ... all subsections of this section or...
final Collection<PieSubSectionDataModel> elements = section.getElements();
for (final PieSubSectionDataModel subSection : elements) {
drawSection(g2, subSection, false);
if (LabelDisplayPolicy.ALL.equals(labelPolicy) || (LabelDisplayPolicy.SELECTED.equals(labelPolicy) && subSection.isSelected())) {
final Rectangle2D labelArea;
if (explode && section.isSelected()) {
labelArea = explodeArea;
} else {
labelArea = pieArea;
}
final String label = m_vizModel.createLabel(section, subSection);
drawLabel(g2, label, labelArea, labelLinkSize, subSection);
}
}
} else {
// ...only the main section itself
drawSection(g2, section, drawOutline);
if (LabelDisplayPolicy.ALL.equals(labelPolicy) || (LabelDisplayPolicy.SELECTED.equals(labelPolicy) && section.isSelected())) {
final Rectangle2D labelArea;
if (explode && section.isSelected()) {
labelArea = explodeArea;
} else {
labelArea = pieArea;
}
final String label = m_vizModel.createLabel(section);
drawLabel(g2, label, labelArea, labelLinkSize, section);
}
}
}
// set the old rendering hints
g2.setRenderingHints(origHints);
// draw the rectangles for debugging
// g2.setStroke(SECTION_OUTLINE_STROKE);
// g2.setColor(Color.CYAN);
// g2.draw(m_vizModel.getLabelArea());
// g2.draw(m_vizModel.getExplodedArea());
// g2.draw(m_vizModel.getPieArea());
}
Aggregations