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

📄 hcoordinate.java

📁 一个简单的visio程序。
💻 JAVA
字号:

package HAB.object;

public class HCoordinate
{
private short scalemode = 1;
private double scaletop = 0;
private double scaleleft = 0;
private double scalewidth;
private double scaleheight;
private double currentx    = 0;
private double currenty    = 0;
private double PhysicalWidth;
private double PhysicalHeight;
private double unitx = 15;
private double unity = 15;           //0.0625
private double mode[] = {0,15.0,0.75,1.0,0.125,(double)1/96,(double)254/960,(double)254/9600};
                                       //6  
private double vbmode[] = {0,1440,72,96,12,1,25.4,2.54,2540};
private boolean canadjust = false;                                           
public HCoordinate()
{ //notice property order
}

public void setPhysicalSize(double pw,double ph,boolean isrun)
{
	PhysicalWidth = java.lang.Math.abs(pw / 15);
	PhysicalHeight = java.lang.Math.abs(ph / 15);
	if (isrun)
	{
		scalewidth  = PhysicalWidth * unitx;
		scaleheight = PhysicalHeight * unity;
	}
	canadjust = true;
}

public double getphysicalwidth()
{
	return PhysicalWidth;
}

public double getphysicalheight()
{
	return PhysicalHeight;
}

public void adjustsize(boolean isx)
{
    if (isx)
	{
		double pcx = currentx / unitx;
		unitx = java.lang.Math.abs(scalewidth / PhysicalWidth);
		currentx = pcx * unitx;
	}
	else
	{
		double pcy = currenty / unity;
		unity = java.lang.Math.abs(scaleheight / PhysicalHeight);
		currenty = pcy * unity;
	}
}

public void scale()
{
	setscalemode((short)1);
}

public void scale(double x1,double y1,double x2,double y2)
{
	setscaleleft(x1);
	setcurrentx(x1);
	setscaletop(y1);
	setcurrenty(y1);
	setscalewidth(x2-x1);
	setscaleheight(y2-y1);
}

public float scalex(double wunits,short mode1,short mode2)
{
	if (mode1 < 1 || mode1 > 8 || mode2 < 1 || mode2 > 8)
		System.out.println("Invalid procedure call or argument");//throw error
	return (float)(wunits * vbmode[mode1] / vbmode[mode2]);
}

public float scaley(double hunits,short mode1,short mode2)
{
	if (mode1 < 1 || mode1 > 8 || mode2 < 1 || mode2 > 8)
		System.out.println("Invalid procedure call or argument");//throw error
	return (float)(hunits * ((mode1 == 4)?6:vbmode[mode1]) / ((mode1 == 4)?6:vbmode[mode1]));
}

public void setcurrentx(double newx)
{
	currentx = newx;
}
public float getcurrentx()
{
	return (float)currentx;
}

public void setcurrenty(double newy)
{
	currenty = newy;
}
public float getcurrenty()
{
	return (float)currenty;
}

public void setscalemode(short newscalemode)
{
	if (newscalemode == 0) return;
	if (newscalemode < 0 || newscalemode > 7) 
	{
		//throw error
		System.out.println("invalid property value");
	}
	if (scalemode != newscalemode)
	{
		scalemode = newscalemode;
		double pcx = currentx / unitx;
		double pcy = currenty / unity;
		unitx = mode[newscalemode];
		unity = (newscalemode == 4)?0.0625:mode[newscalemode];
		currentx = pcx * unitx;
		currenty = pcy * unity;
		if (canadjust)
		{
			scaleheight = PhysicalHeight * unity;
			scalewidth = PhysicalWidth * unitx;
		}
	}
}
public short getscalemode()
{
	return scalemode;
}

public double getunitx()
{
	return unitx;
}

public double getunity()
{
	return unity;
}

public void setscaletop(double newscaletop)
{
	scalemode = 0;
	currenty = currenty + scaletop;
	scaletop = newscaletop;
}
public float getscaletop()
{
	return (float)scaletop;
}

public void setscaleleft(double newscaleleft)
{
	scalemode = 0;
	currentx = currentx + scaleleft;
    scaleleft = newscaleleft;
}
public float getscaleleft()
{
	return (float)scaleleft;
}

public void setscalewidth(double newscalewidth)
{
	scalemode = 0; // the first time should not change to zero.
	scalewidth = newscalewidth;
	if (canadjust) adjustsize(true);
}
public float getscalewidth()
{
	return (float)scalewidth;
}

public void setscaleheight(double newscaleheight)
{
	scalemode = 0;
	scaleheight = newscaleheight;
	if (canadjust) adjustsize(false);
}
public float getscaleheight()
{
	return (float)scaleheight;
}
}

⌨️ 快捷键说明

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