本文整理汇总了Java中sun.font.GraphicComponent类的典型用法代码示例。如果您正苦于以下问题:Java GraphicComponent类的具体用法?Java GraphicComponent怎么用?Java GraphicComponent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GraphicComponent类属于sun.font包,在下文中一共展示了GraphicComponent类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getComponents
import sun.font.GraphicComponent; //导入依赖的package包/类
/**
* Returns an array (in logical order) of the TextLineComponents representing
* the text. The components are both logically and visually contiguous.
*/
public static TextLineComponent[] getComponents(StyledParagraph styledParagraph,
char[] chars,
int textStart,
int textLimit,
int[] charsLtoV,
byte[] levels,
TextLabelFactory factory) {
FontRenderContext frc = factory.getFontRenderContext();
int numComponents = 0;
TextLineComponent[] tempComponents = new TextLineComponent[1];
int pos = textStart;
do {
int runLimit = Math.min(styledParagraph.getRunLimit(pos), textLimit);
Decoration decorator = styledParagraph.getDecorationAt(pos);
Object graphicOrFont = styledParagraph.getFontOrGraphicAt(pos);
if (graphicOrFont instanceof GraphicAttribute) {
// AffineTransform baseRot = styledParagraph.getBaselineRotationAt(pos);
// !!! For now, let's assign runs of text with both fonts and graphic attributes
// a null rotation (e.g. the baseline rotation goes away when a graphic
// is applied.
AffineTransform baseRot = null;
GraphicAttribute graphicAttribute = (GraphicAttribute) graphicOrFont;
do {
int chunkLimit = firstVisualChunk(charsLtoV, levels,
pos, runLimit);
GraphicComponent nextGraphic =
new GraphicComponent(graphicAttribute, decorator, charsLtoV, levels, pos, chunkLimit, baseRot);
pos = chunkLimit;
++numComponents;
if (numComponents >= tempComponents.length) {
tempComponents = expandArray(tempComponents);
}
tempComponents[numComponents-1] = nextGraphic;
} while(pos < runLimit);
}
else {
Font font = (Font) graphicOrFont;
tempComponents = createComponentsOnRun(pos, runLimit,
chars,
charsLtoV, levels,
factory, font, null,
frc,
decorator,
tempComponents,
numComponents);
pos = runLimit;
numComponents = tempComponents.length;
while (tempComponents[numComponents-1] == null) {
numComponents -= 1;
}
}
} while (pos < textLimit);
TextLineComponent[] components;
if (tempComponents.length == numComponents) {
components = tempComponents;
}
else {
components = new TextLineComponent[numComponents];
System.arraycopy(tempComponents, 0, components, 0, numComponents);
}
return components;
}
示例2: getComponents
import sun.font.GraphicComponent; //导入依赖的package包/类
/**
* Returns an array (in logical order) of the TextLineComponents representing
* the text. The components are both logically and visually contiguous.
*/
public static TextLineComponent[] getComponents(StyledParagraph styledParagraph,
char[] chars,
int textStart,
int textLimit,
int[] charsLtoV,
byte[] levels,
TextLabelFactory factory) {
FontRenderContext frc = factory.getFontRenderContext();
int numComponents = 0;
TextLineComponent[] tempComponents = new TextLineComponent[1];
int pos = textStart;
do {
int runLimit = Math.min(styledParagraph.getRunLimit(pos), textLimit);
Decoration decorator = styledParagraph.getDecorationAt(pos);
Object graphicOrFont = styledParagraph.getFontOrGraphicAt(pos);
if (graphicOrFont instanceof GraphicAttribute) {
// AffineTransform baseRot = styledParagraph.getBaselineRotationAt(pos);
// !!! For now, let's assign runs of text with both fonts and graphic attributes
// a null rotation (e.g. the baseline rotation goes away when a graphic
// is applied.
AffineTransform baseRot = null;
GraphicAttribute graphicAttribute = (GraphicAttribute) graphicOrFont;
do {
int chunkLimit = firstVisualChunk(charsLtoV, levels,
pos, runLimit);
GraphicComponent nextGraphic =
new GraphicComponent(graphicAttribute, decorator, charsLtoV, levels, pos, chunkLimit, baseRot);
pos = chunkLimit;
++numComponents;
if (numComponents >= tempComponents.length) {
tempComponents = expandArray(tempComponents);
}
tempComponents[numComponents-1] = nextGraphic;
} while(pos < runLimit);
}
else {
Font font = (Font) graphicOrFont;
tempComponents = createComponentsOnRun(pos, runLimit,
chars,
charsLtoV, levels,
factory, font, null,
frc,
decorator,
tempComponents,
numComponents);
pos = runLimit;
numComponents = tempComponents.length;
while (tempComponents[numComponents-1] == null) {
numComponents -= 1;
}
}
} while (pos < textLimit);
TextLineComponent[] components;
if (tempComponents.length == numComponents) {
components = tempComponents;
}
else {
components = new TextLineComponent[numComponents];
System.arraycopy(tempComponents, 0, components, 0, numComponents);
}
return components;
}