stretchtemplate.java
来自「Sony Ericsson手机上的Facebook客户端全套代码」· Java 代码 · 共 129 行
JAVA
129 行
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3)
// Source File Name: StretchTemplate.java
package se.southend.drops.gui;
import java.util.Vector;
public class StretchTemplate
{
public StretchTemplate()
{
sourceWidth = 0;
sourceHeight = 0;
minTextureWidth = 0;
minTextureHeight = 0;
isScalableX = false;
isScalableY = false;
rowHeight = new Vector();
rowScale = new Vector();
colWidth = new Vector();
colScale = new Vector();
}
public void addRow(int height, int scale)
{
rowHeight.addElement(new Integer(height));
rowScale.addElement(new Integer(scale));
sourceHeight += height;
if(scale == 0)
minTextureHeight += height;
else
isScalableY = true;
}
public void addColumn(int width, int scale)
{
colWidth.addElement(new Integer(width));
colScale.addElement(new Integer(scale));
sourceWidth += width;
if(scale == 0)
minTextureWidth += width;
else
isScalableX = true;
}
private Vector getDestWidths(Vector partWidth, Vector partScale, int srcWidth, int fixedWidth, int wantedWidth)
{
Vector widths = new Vector();
int sum = 0;
int availStretch = srcWidth - fixedWidth;
int totalStretch = wantedWidth - fixedWidth;
for(int i = 0; i < partWidth.size(); i++)
{
int currentPartWidth = ((Integer)partWidth.elementAt(i)).intValue();
int currentPartScale = ((Integer)partScale.elementAt(i)).intValue();
int width;
if(currentPartScale == 0)
width = currentPartWidth;
else
width = (currentPartWidth * totalStretch) / availStretch;
sum += currentPartWidth;
widths.addElement(new Integer(width));
}
for(int i = 0; i < widths.size() && sum < wantedWidth; i++)
{
int currentPartScale = ((Integer)partScale.elementAt(i)).intValue();
if(currentPartScale != 0)
{
int prevWidth = ((Integer)widths.elementAt(i)).intValue();
widths.setElementAt(new Integer(prevWidth + 1), i);
}
}
return widths;
}
public Vector getWidths(int totalWidth)
{
return getDestWidths(colWidth, colScale, sourceWidth, minTextureWidth, totalWidth);
}
public Vector getHeights(int totalHeight)
{
return getDestWidths(rowHeight, rowScale, sourceHeight, minTextureHeight, totalHeight);
}
public int getSourceWidth()
{
return sourceWidth;
}
public int getSourceHeight()
{
return sourceHeight;
}
public boolean isSizePossible(int width, int height)
{
return width >= minTextureWidth && height >= minTextureHeight && (isScalableX || width == sourceWidth) && (isScalableY || height == sourceHeight);
}
public int getSourceRowHeight(int rowIndex)
{
return ((Integer)rowHeight.elementAt(rowIndex)).intValue();
}
public int getSourceColumnWidth(int columnIndex)
{
return ((Integer)colWidth.elementAt(columnIndex)).intValue();
}
public static final int SCALE_NO = 0;
public static final int SCALE_REPEAT = 1;
private int sourceWidth;
private int sourceHeight;
private int minTextureWidth;
private int minTextureHeight;
private boolean isScalableX;
private boolean isScalableY;
private Vector rowHeight;
private Vector rowScale;
private Vector colWidth;
private Vector colScale;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?