下面列出了怎么用java.awt.font.GraphicAttribute的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Create a new GraphicComponent. start and limit are indices
* into charLtoV and levels. charsLtoV and levels may be adopted.
*/
public GraphicComponent(GraphicAttribute graphic,
Decoration decorator,
int[] charsLtoV,
byte[] levels,
int start,
int limit,
AffineTransform baseTx) {
if (limit <= start) {
throw new IllegalArgumentException("0 or negative length in GraphicComponent");
}
this.graphic = graphic;
this.graphicAdvance = graphic.getAdvance();
this.decorator = decorator;
this.cm = createCoreMetrics(graphic);
this.baseTx = baseTx;
initLocalOrdering(charsLtoV, levels, start, limit);
}
/**
* Create a new GraphicComponent. start and limit are indices
* into charLtoV and levels. charsLtoV and levels may be adopted.
*/
public GraphicComponent(GraphicAttribute graphic,
Decoration decorator,
int[] charsLtoV,
byte[] levels,
int start,
int limit,
AffineTransform baseTx) {
if (limit <= start) {
throw new IllegalArgumentException("0 or negative length in GraphicComponent");
}
this.graphic = graphic;
this.graphicAdvance = graphic.getAdvance();
this.decorator = decorator;
this.cm = createCoreMetrics(graphic);
this.baseTx = baseTx;
initLocalOrdering(charsLtoV, levels, start, limit);
}
/**
* Create a new GraphicComponent. start and limit are indices
* into charLtoV and levels. charsLtoV and levels may be adopted.
*/
public GraphicComponent(GraphicAttribute graphic,
Decoration decorator,
int[] charsLtoV,
byte[] levels,
int start,
int limit,
AffineTransform baseTx) {
if (limit <= start) {
throw new IllegalArgumentException("0 or negative length in GraphicComponent");
}
this.graphic = graphic;
this.graphicAdvance = graphic.getAdvance();
this.decorator = decorator;
this.cm = createCoreMetrics(graphic);
this.baseTx = baseTx;
initLocalOrdering(charsLtoV, levels, start, limit);
}
/**
* Create a new GraphicComponent. start and limit are indices
* into charLtoV and levels. charsLtoV and levels may be adopted.
*/
public GraphicComponent(GraphicAttribute graphic,
Decoration decorator,
int[] charsLtoV,
byte[] levels,
int start,
int limit,
AffineTransform baseTx) {
if (limit <= start) {
throw new IllegalArgumentException("0 or negative length in GraphicComponent");
}
this.graphic = graphic;
this.graphicAdvance = graphic.getAdvance();
this.decorator = decorator;
this.cm = createCoreMetrics(graphic);
this.baseTx = baseTx;
initLocalOrdering(charsLtoV, levels, start, limit);
}
/**
* Create a new GraphicComponent. start and limit are indices
* into charLtoV and levels. charsLtoV and levels may be adopted.
*/
public GraphicComponent(GraphicAttribute graphic,
Decoration decorator,
int[] charsLtoV,
byte[] levels,
int start,
int limit,
AffineTransform baseTx) {
if (limit <= start) {
throw new IllegalArgumentException("0 or negative length in GraphicComponent");
}
this.graphic = graphic;
this.graphicAdvance = graphic.getAdvance();
this.decorator = decorator;
this.cm = createCoreMetrics(graphic);
this.baseTx = baseTx;
initLocalOrdering(charsLtoV, levels, start, limit);
}
/**
* Create a new GraphicComponent. start and limit are indices
* into charLtoV and levels. charsLtoV and levels may be adopted.
*/
public GraphicComponent(GraphicAttribute graphic,
Decoration decorator,
int[] charsLtoV,
byte[] levels,
int start,
int limit,
AffineTransform baseTx) {
if (limit <= start) {
throw new IllegalArgumentException("0 or negative length in GraphicComponent");
}
this.graphic = graphic;
this.graphicAdvance = graphic.getAdvance();
this.decorator = decorator;
this.cm = createCoreMetrics(graphic);
this.baseTx = baseTx;
initLocalOrdering(charsLtoV, levels, start, limit);
}
/**
* Create a new GraphicComponent. start and limit are indices
* into charLtoV and levels. charsLtoV and levels may be adopted.
*/
public GraphicComponent(GraphicAttribute graphic,
Decoration decorator,
int[] charsLtoV,
byte[] levels,
int start,
int limit,
AffineTransform baseTx) {
if (limit <= start) {
throw new IllegalArgumentException("0 or negative length in GraphicComponent");
}
this.graphic = graphic;
this.graphicAdvance = graphic.getAdvance();
this.decorator = decorator;
this.cm = createCoreMetrics(graphic);
this.baseTx = baseTx;
initLocalOrdering(charsLtoV, levels, start, limit);
}
/**
* Create a new GraphicComponent. start and limit are indices
* into charLtoV and levels. charsLtoV and levels may be adopted.
*/
public GraphicComponent(GraphicAttribute graphic,
Decoration decorator,
int[] charsLtoV,
byte[] levels,
int start,
int limit,
AffineTransform baseTx) {
if (limit <= start) {
throw new IllegalArgumentException("0 or negative length in GraphicComponent");
}
this.graphic = graphic;
this.graphicAdvance = graphic.getAdvance();
this.decorator = decorator;
this.cm = createCoreMetrics(graphic);
this.baseTx = baseTx;
initLocalOrdering(charsLtoV, levels, start, limit);
}
/**
* Create a new GraphicComponent. start and limit are indices
* into charLtoV and levels. charsLtoV and levels may be adopted.
*/
public GraphicComponent(GraphicAttribute graphic,
Decoration decorator,
int[] charsLtoV,
byte[] levels,
int start,
int limit,
AffineTransform baseTx) {
if (limit <= start) {
throw new IllegalArgumentException("0 or negative length in GraphicComponent");
}
this.graphic = graphic;
this.graphicAdvance = graphic.getAdvance();
this.decorator = decorator;
this.cm = createCoreMetrics(graphic);
this.baseTx = baseTx;
initLocalOrdering(charsLtoV, levels, start, limit);
}
/**
* Create a new GraphicComponent. start and limit are indices
* into charLtoV and levels. charsLtoV and levels may be adopted.
*/
public GraphicComponent(GraphicAttribute graphic,
Decoration decorator,
int[] charsLtoV,
byte[] levels,
int start,
int limit,
AffineTransform baseTx) {
if (limit <= start) {
throw new IllegalArgumentException("0 or negative length in GraphicComponent");
}
this.graphic = graphic;
this.graphicAdvance = graphic.getAdvance();
this.decorator = decorator;
this.cm = createCoreMetrics(graphic);
this.baseTx = baseTx;
initLocalOrdering(charsLtoV, levels, start, limit);
}
/**
* Create a new GraphicComponent. start and limit are indices
* into charLtoV and levels. charsLtoV and levels may be adopted.
*/
public GraphicComponent(GraphicAttribute graphic,
Decoration decorator,
int[] charsLtoV,
byte[] levels,
int start,
int limit,
AffineTransform baseTx) {
if (limit <= start) {
throw new IllegalArgumentException("0 or negative length in GraphicComponent");
}
this.graphic = graphic;
this.graphicAdvance = graphic.getAdvance();
this.decorator = decorator;
this.cm = createCoreMetrics(graphic);
this.baseTx = baseTx;
initLocalOrdering(charsLtoV, levels, start, limit);
}
/**
* Create a new GraphicComponent. start and limit are indices
* into charLtoV and levels. charsLtoV and levels may be adopted.
*/
public GraphicComponent(GraphicAttribute graphic,
Decoration decorator,
int[] charsLtoV,
byte[] levels,
int start,
int limit,
AffineTransform baseTx) {
if (limit <= start) {
throw new IllegalArgumentException("0 or negative length in GraphicComponent");
}
this.graphic = graphic;
this.graphicAdvance = graphic.getAdvance();
this.decorator = decorator;
this.cm = createCoreMetrics(graphic);
this.baseTx = baseTx;
initLocalOrdering(charsLtoV, levels, start, limit);
}
/**
* Create a new GraphicComponent. start and limit are indices
* into charLtoV and levels. charsLtoV and levels may be adopted.
*/
public GraphicComponent(GraphicAttribute graphic,
Decoration decorator,
int[] charsLtoV,
byte[] levels,
int start,
int limit,
AffineTransform baseTx) {
if (limit <= start) {
throw new IllegalArgumentException("0 or negative length in GraphicComponent");
}
this.graphic = graphic;
this.graphicAdvance = graphic.getAdvance();
this.decorator = decorator;
this.cm = createCoreMetrics(graphic);
this.baseTx = baseTx;
initLocalOrdering(charsLtoV, levels, start, limit);
}
/**
* Create a new GraphicComponent. start and limit are indices
* into charLtoV and levels. charsLtoV and levels may be adopted.
*/
public GraphicComponent(GraphicAttribute graphic,
Decoration decorator,
int[] charsLtoV,
byte[] levels,
int start,
int limit,
AffineTransform baseTx) {
if (limit <= start) {
throw new IllegalArgumentException("0 or negative length in GraphicComponent");
}
this.graphic = graphic;
this.graphicAdvance = graphic.getAdvance();
this.decorator = decorator;
this.cm = createCoreMetrics(graphic);
this.baseTx = baseTx;
initLocalOrdering(charsLtoV, levels, start, limit);
}
public static AttributedString textIconReplace(final String text) {
final String compacted = text.replaceAll("\\{[^}]+}", "M");
final AttributedString attrString = new AttributedString(compacted);
for (int i = 0, j = 0; i < text.length(); i++, j++) {
char c = text.charAt(i);
if (c == '{') {
final int endSymbol = text.indexOf('}', i);
// get mana-string, substring returns at -1 value
String iconString = text.substring(i, endSymbol + 1);
// get related Icon as Image
Image iconImage = MagicImages.getIcon(iconString).getImage();
// define replacement icon
ImageGraphicAttribute icon = new ImageGraphicAttribute(iconImage, GraphicAttribute.BOTTOM_ALIGNMENT);
// replace M with icon
attrString.addAttribute(
TextAttribute.CHAR_REPLACEMENT,
icon,
j,
j + 1
);
// advance i to the end of symbol
i = endSymbol;
}
}
return attrString;
}
public static CoreMetrics createCoreMetrics(GraphicAttribute graphic) {
return new CoreMetrics(graphic.getAscent(),
graphic.getDescent(),
GRAPHIC_LEADING,
graphic.getAscent() + graphic.getDescent() + GRAPHIC_LEADING,
graphic.getAlignment(),
new float[] { 0, -graphic.getAscent() / 2, -graphic.getAscent() },
-graphic.getAscent() / 2,
graphic.getAscent() / 12,
graphic.getDescent() / 3,
graphic.getAscent() / 12,
0, // ss offset
0); // italic angle -- need api for this
}
public final float effectiveBaselineOffset(float[] fullOffsets) {
switch (baselineIndex) {
case GraphicAttribute.TOP_ALIGNMENT:
return fullOffsets[4] + ascent;
case GraphicAttribute.BOTTOM_ALIGNMENT:
return fullOffsets[3] - descent;
default:
return fullOffsets[baselineIndex];
}
}
public static CoreMetrics createCoreMetrics(GraphicAttribute graphic) {
return new CoreMetrics(graphic.getAscent(),
graphic.getDescent(),
GRAPHIC_LEADING,
graphic.getAscent() + graphic.getDescent() + GRAPHIC_LEADING,
graphic.getAlignment(),
new float[] { 0, -graphic.getAscent() / 2, -graphic.getAscent() },
-graphic.getAscent() / 2,
graphic.getAscent() / 12,
graphic.getDescent() / 3,
graphic.getAscent() / 12,
0, // ss offset
0); // italic angle -- need api for this
}
public final float effectiveBaselineOffset(float[] fullOffsets) {
switch (baselineIndex) {
case GraphicAttribute.TOP_ALIGNMENT:
return fullOffsets[4] + ascent;
case GraphicAttribute.BOTTOM_ALIGNMENT:
return fullOffsets[3] - descent;
default:
return fullOffsets[baselineIndex];
}
}
public static CoreMetrics createCoreMetrics(GraphicAttribute graphic) {
return new CoreMetrics(graphic.getAscent(),
graphic.getDescent(),
GRAPHIC_LEADING,
graphic.getAscent() + graphic.getDescent() + GRAPHIC_LEADING,
graphic.getAlignment(),
new float[] { 0, -graphic.getAscent() / 2, -graphic.getAscent() },
-graphic.getAscent() / 2,
graphic.getAscent() / 12,
graphic.getDescent() / 3,
graphic.getAscent() / 12,
0, // ss offset
0); // italic angle -- need api for this
}
public final float effectiveBaselineOffset(float[] fullOffsets) {
switch (baselineIndex) {
case GraphicAttribute.TOP_ALIGNMENT:
return fullOffsets[4] + ascent;
case GraphicAttribute.BOTTOM_ALIGNMENT:
return fullOffsets[3] - descent;
default:
return fullOffsets[baselineIndex];
}
}
public static CoreMetrics createCoreMetrics(GraphicAttribute graphic) {
return new CoreMetrics(graphic.getAscent(),
graphic.getDescent(),
GRAPHIC_LEADING,
graphic.getAscent() + graphic.getDescent() + GRAPHIC_LEADING,
graphic.getAlignment(),
new float[] { 0, -graphic.getAscent() / 2, -graphic.getAscent() },
-graphic.getAscent() / 2,
graphic.getAscent() / 12,
graphic.getDescent() / 3,
graphic.getAscent() / 12,
0, // ss offset
0); // italic angle -- need api for this
}
public final float effectiveBaselineOffset(float[] fullOffsets) {
switch (baselineIndex) {
case GraphicAttribute.TOP_ALIGNMENT:
return fullOffsets[4] + ascent;
case GraphicAttribute.BOTTOM_ALIGNMENT:
return fullOffsets[3] - descent;
default:
return fullOffsets[baselineIndex];
}
}
public static CoreMetrics createCoreMetrics(GraphicAttribute graphic) {
return new CoreMetrics(graphic.getAscent(),
graphic.getDescent(),
GRAPHIC_LEADING,
graphic.getAscent() + graphic.getDescent() + GRAPHIC_LEADING,
graphic.getAlignment(),
new float[] { 0, -graphic.getAscent() / 2, -graphic.getAscent() },
-graphic.getAscent() / 2,
graphic.getAscent() / 12,
graphic.getDescent() / 3,
graphic.getAscent() / 12,
0, // ss offset
0); // italic angle -- need api for this
}
public final float effectiveBaselineOffset(float[] fullOffsets) {
switch (baselineIndex) {
case GraphicAttribute.TOP_ALIGNMENT:
return fullOffsets[4] + ascent;
case GraphicAttribute.BOTTOM_ALIGNMENT:
return fullOffsets[3] - descent;
default:
return fullOffsets[baselineIndex];
}
}
public static CoreMetrics createCoreMetrics(GraphicAttribute graphic) {
return new CoreMetrics(graphic.getAscent(),
graphic.getDescent(),
GRAPHIC_LEADING,
graphic.getAscent() + graphic.getDescent() + GRAPHIC_LEADING,
graphic.getAlignment(),
new float[] { 0, -graphic.getAscent() / 2, -graphic.getAscent() },
-graphic.getAscent() / 2,
graphic.getAscent() / 12,
graphic.getDescent() / 3,
graphic.getAscent() / 12,
0, // ss offset
0); // italic angle -- need api for this
}
public float effectiveBaselineOffset(float[] fullOffsets) {
switch (baselineIndex) {
case GraphicAttribute.TOP_ALIGNMENT:
return fullOffsets[4] + ascent;
case GraphicAttribute.BOTTOM_ALIGNMENT:
return fullOffsets[3] - descent;
default:
return fullOffsets[baselineIndex];
}
}
public static CoreMetrics createCoreMetrics(GraphicAttribute graphic) {
return new CoreMetrics(graphic.getAscent(),
graphic.getDescent(),
GRAPHIC_LEADING,
graphic.getAscent() + graphic.getDescent() + GRAPHIC_LEADING,
graphic.getAlignment(),
new float[] { 0, -graphic.getAscent() / 2, -graphic.getAscent() },
-graphic.getAscent() / 2,
graphic.getAscent() / 12,
graphic.getDescent() / 3,
graphic.getAscent() / 12,
0, // ss offset
0); // italic angle -- need api for this
}
public float effectiveBaselineOffset(float[] fullOffsets) {
switch (baselineIndex) {
case GraphicAttribute.TOP_ALIGNMENT:
return fullOffsets[4] + ascent;
case GraphicAttribute.BOTTOM_ALIGNMENT:
return fullOffsets[3] - descent;
default:
return fullOffsets[baselineIndex];
}
}
public static CoreMetrics createCoreMetrics(GraphicAttribute graphic) {
return new CoreMetrics(graphic.getAscent(),
graphic.getDescent(),
GRAPHIC_LEADING,
graphic.getAscent() + graphic.getDescent() + GRAPHIC_LEADING,
graphic.getAlignment(),
new float[] { 0, -graphic.getAscent() / 2, -graphic.getAscent() },
-graphic.getAscent() / 2,
graphic.getAscent() / 12,
graphic.getDescent() / 3,
graphic.getAscent() / 12,
0, // ss offset
0); // italic angle -- need api for this
}