⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sizemeasure.java

📁 Novocode的 SWT 控件框架 丰富了MDI功能
💻 JAVA
字号:
/*******************************************************************************
 * Copyright (c) 2004 Stefan Zeiger and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.novocode.com/legal/epl-v10.html
 * 
 * Contributors:
 *     Stefan Zeiger (szeiger@novocode.com) - initial API and implementation
 *******************************************************************************/

package com.novocode.naf.data;


/**
 * Contains a decoded size which can depend on "em" and "%" measures.
 * 
 * @author Stefan Zeiger (szeiger@novocode.com)
 * @since Dec 16, 2003
 * @version $Id: SizeMeasure.java,v 1.1 2004/12/18 16:14:38 szeiger Exp $
 */

public final class SizeMeasure
{
  public final double baseSize;
  public final double emFactor;
  public final double scaleFactor;

  
  public SizeMeasure(double baseSize, double emFactor, double scaleFactor)
  {
    this.baseSize = baseSize;
    this.emFactor= emFactor;
    this.scaleFactor = scaleFactor;
  }
  
  
  public SizeMeasure(double baseSize)
  {
    this.baseSize = baseSize;
    this.emFactor= 0.0;
    this.scaleFactor = 0.0;
  }
  
  
  public int compute(int emSize, int scaleSize)
  {
    double d = baseSize + (emFactor * emSize);
    if(scaleSize > 0) d += (scaleFactor * scaleSize);
    if(d < 0) return (int)(d - 0.5);
    else return (int)(d + 0.5);
  }

  
  public int compute(int emSize)
  {
    return compute(emSize, 0);
  }

  
  public String toString()
  {
    if(scaleFactor != 0) return (scaleFactor*100)+"%";
    else if(emFactor != 0) return emFactor+"em";
    else return baseSize+"px";
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -