什么是scaledSize(Legend.FontSpec)

时间:2015-10-09 12:40:39

标签: c# zedgraph

我正在尝试在ZedGraph上设置图例的字体大小。但是,尺寸永远不会像我设置的那样出现。

我浏览了GraphPane.Legend.FontSpec对象并找到了scaledSize私有变量。这似乎是实际显示的大小。例如我将Size设置为10,但scaledSize = 16.09

这个价值来自哪里?我查看了我的代码(我接管了其他人的项目,它是一个大项目,所以它不容易找到)和ZedGraph对象中的其他地方用于某种扩展项目,但可以&# 39;找到如何设置这个值。它是以某种方式自动计算的吗?

我已经在网上搜索了答案,但无济于事。

2 个答案:

答案 0 :(得分:0)

这是Size

的制定者
set
{
    if ( value != _size )
    {
        Remake( _scaledSize / _size * value, _size, ref _scaledSize,
                    ref _font );
        _size = value;
    }
}
//...

/// <summary>
/// Recreate the font based on a new scaled size.  The font
/// will only be recreated if the scaled size has changed by
/// at least 0.1 points.
/// </summary>
/// <param name="scaleFactor">
/// The scaling factor to be used for rendering objects.  This is calculated and
/// passed down by the parent <see cref="GraphPane"/> object using the
/// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
/// font sizes, etc. according to the actual size of the graph.
/// </param>
/// <param name="size">The unscaled size of the font, in points</param>
/// <param name="scaledSize">The scaled size of the font, in points</param>
/// <param name="font">A reference to the <see cref="Font"/> object</param>
private void Remake( float scaleFactor, float size, ref float scaledSize, ref Font font )
{
    float newSize = size * scaleFactor;

    float oldSize = ( font == null ) ? 0.0f : font.Size;

    // Regenerate the font only if the size has changed significantly
    if ( font == null ||
            Math.Abs( newSize - oldSize ) > 0.1 ||
            font.Name != this.Family ||
            font.Bold != _isBold ||
            font.Italic != _isItalic ||
            font.Underline != _isUnderline )
    {
        FontStyle style = FontStyle.Regular;
        style = ( _isBold ? FontStyle.Bold : style ) |
                    ( _isItalic ? FontStyle.Italic : style ) |
                     ( _isUnderline ? FontStyle.Underline : style );

        scaledSize = size * (float)scaleFactor;
        font = new Font( _family, scaledSize, style, GraphicsUnit.World );
    }
}

有趣的路线是:

scaledSize = size * (float)scaleFactor;
font = new Font( _family, scaledSize, style, GraphicsUnit.World );

这意味着您的尺寸使用PaneBase.CalcScaleFactor进行缩放。你应该看看最后一个

答案 1 :(得分:0)

ZedGraph会根据窗格的大小自动缩放所有字体。

这是通过import hudson.model.* def jobsToDelete = [] // For each project for(item in Hudson.instance.items) { // check that job is not building if(!item.isBuilding()) { if (item.scm instanceof hudson.plugins.git.GitSCM) { println("Item name: " + item.name); item.scm.repositories.each { println("Repo " + it.name); it.URIs.each {uri -> println("URI: " + uri.toString()); item.scm.branches.each { println("Branch " + it.name); // Skip empty/regex branch definitions if (it.name.length() != 0 && it.name.indexOf("*") > -1) { // Use git ls-remote to verify branch existence def command = "git ls-remote --heads " + uri + " " + it.name def sout = new StringBuffer(), serr = new StringBuffer() Process proc = command.execute() proc.consumeProcessOutput(sout, serr) proc.waitFor() println("SOUT: " + sout) if (sout.size() == 0) { println("Branch does not exist") jobsToDelete << item } } } } } } } else { println("Skipping job "+item.name+", currently building") } } jobsToDelete.each { println("Job to delete: " + it.name) it.delete() } 属性控制的。将此设置为false,您的字体应保持您设置的大小。