本文整理汇总了Java中sun.font.AttributeValues类的典型用法代码示例。如果您正苦于以下问题:Java AttributeValues类的具体用法?Java AttributeValues怎么用?Java AttributeValues使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AttributeValues类属于sun.font包,在下文中一共展示了AttributeValues类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paragraphInit
import sun.font.AttributeValues; //导入依赖的package包/类
/**
* Initialize the paragraph-specific data.
*/
private void paragraphInit(byte aBaseline, CoreMetrics lm,
Map<? extends Attribute, ?> paragraphAttrs,
char[] text) {
baseline = aBaseline;
// normalize to current baseline
baselineOffsets = TextLine.getNormalizedOffsets(lm.baselineOffsets, baseline);
justifyRatio = AttributeValues.getJustification(paragraphAttrs);
NumericShaper shaper = AttributeValues.getNumericShaping(paragraphAttrs);
if (shaper != null) {
shaper.shape(text, 0, text.length);
}
}
示例2: getAttributeValues
import sun.font.AttributeValues; //导入依赖的package包/类
/**
* Return the AttributeValues object associated with this
* font. Most of the time, the internal object is null.
* If required, it will be created from the 'standard'
* state on the font. Only non-default values will be
* set in the AttributeValues object.
*
* <p>Since the AttributeValues object is mutable, and it
* is cached in the font, care must be taken to ensure that
* it is not mutated.
*/
private AttributeValues getAttributeValues() {
if (values == null) {
AttributeValues valuesTmp = new AttributeValues();
valuesTmp.setFamily(name);
valuesTmp.setSize(pointSize); // expects the float value.
if ((style & BOLD) != 0) {
valuesTmp.setWeight(2); // WEIGHT_BOLD
}
if ((style & ITALIC) != 0) {
valuesTmp.setPosture(.2f); // POSTURE_OBLIQUE
}
valuesTmp.defineAll(PRIMARY_MASK); // for streaming compatibility
values = valuesTmp;
}
return values;
}
示例3: Font
import sun.font.AttributeValues; //导入依赖的package包/类
private Font(AttributeValues values, String oldName, int oldStyle,
boolean created, Font2DHandle handle) {
this.createdFont = created;
if (created) {
this.font2DHandle = handle;
String newName = null;
if (oldName != null) {
newName = values.getFamily();
if (oldName.equals(newName)) newName = null;
}
int newStyle = 0;
if (oldStyle == -1) {
newStyle = -1;
} else {
if (values.getWeight() >= 2f) newStyle = BOLD;
if (values.getPosture() >= .2f) newStyle |= ITALIC;
if (oldStyle == newStyle) newStyle = -1;
}
if (handle.font2D instanceof CompositeFont) {
if (newStyle != -1 || newName != null) {
FontManager fm = FontManagerFactory.getInstance();
this.font2DHandle =
fm.getNewComposite(newName, newStyle, handle);
}
} else if (newName != null) {
this.createdFont = false;
this.font2DHandle = null;
}
}
initFromValues(values);
}
示例4: initFromValues
import sun.font.AttributeValues; //导入依赖的package包/类
/**
* Initialize the standard Font fields from the values object.
*/
private void initFromValues(AttributeValues values) {
this.values = values;
values.defineAll(PRIMARY_MASK); // for 1.5 streaming compatibility
this.name = values.getFamily();
this.pointSize = values.getSize();
this.size = (int)(values.getSize() + 0.5);
if (values.getWeight() >= 2f) this.style |= BOLD; // not == 2f
if (values.getPosture() >= .2f) this.style |= ITALIC; // not == .2f
this.nonIdentityTx = values.anyNonDefault(EXTRA_MASK);
this.hasLayoutAttributes = values.anyNonDefault(LAYOUT_MASK);
}
示例5: readObject
import sun.font.AttributeValues; //导入依赖的package包/类
/**
* Reads the <code>ObjectInputStream</code>.
* Unrecognized keys or values will be ignored.
*
* @param s the <code>ObjectInputStream</code> to read
* @serial
* @see #writeObject(java.io.ObjectOutputStream)
*/
private void readObject(java.io.ObjectInputStream s)
throws java.lang.ClassNotFoundException,
java.io.IOException
{
s.defaultReadObject();
if (pointSize == 0) {
pointSize = (float)size;
}
// Handle fRequestedAttributes.
// in 1.5, we always streamed out the font values plus
// TRANSFORM, SUPERSCRIPT, and WIDTH, regardless of whether the
// values were default or not. In 1.6 we only stream out
// defined values. So, 1.6 streams in from a 1.5 stream,
// it check each of these values and 'undefines' it if the
// value is the default.
if (fRequestedAttributes != null) {
values = getAttributeValues(); // init
AttributeValues extras =
AttributeValues.fromSerializableHashtable(fRequestedAttributes);
if (!AttributeValues.is16Hashtable(fRequestedAttributes)) {
extras.unsetDefault(); // if legacy stream, undefine these
}
values = getAttributeValues().merge(extras);
this.nonIdentityTx = values.anyNonDefault(EXTRA_MASK);
this.hasLayoutAttributes = values.anyNonDefault(LAYOUT_MASK);
fRequestedAttributes = null; // don't need it any more
}
}
示例6: deriveFont
import sun.font.AttributeValues; //导入依赖的package包/类
/**
* Creates a new <code>Font</code> object by replicating this
* <code>Font</code> object and applying a new style and size.
* @param style the style for the new <code>Font</code>
* @param size the size for the new <code>Font</code>
* @return a new <code>Font</code> object.
* @since 1.2
*/
public Font deriveFont(int style, float size){
if (values == null) {
return new Font(name, style, size, createdFont, font2DHandle);
}
AttributeValues newValues = getAttributeValues().clone();
int oldStyle = (this.style != style) ? this.style : -1;
applyStyle(style, newValues);
newValues.setSize(size);
return new Font(newValues, null, oldStyle, createdFont, font2DHandle);
}