📄 annotationattributes.java
字号:
restorableSupport.addStateValueAsInteger(insetsStateObj, "top", source.insets.top);
restorableSupport.addStateValueAsInteger(insetsStateObj, "left", source.insets.left);
restorableSupport.addStateValueAsInteger(insetsStateObj, "bottom", source.insets.bottom);
restorableSupport.addStateValueAsInteger(insetsStateObj, "right", source.insets.right);
}
}
if (source.borderWidth >= 0)
restorableSupport.addStateValueAsDouble(context, "borderWidth", source.borderWidth);
if (source.borderStippleFactor >= 0)
restorableSupport.addStateValueAsInteger(context, "borderStippleFactor", source.borderStippleFactor);
if (source.borderStipplePattern != (short) 0x0000)
restorableSupport.addStateValueAsInteger(context, "borderStipplePattern", source.borderStipplePattern);
if (source.antiAliasHint >= 0)
restorableSupport.addStateValueAsInteger(context, "antiAliasHint", source.antiAliasHint);
restorableSupport.addStateValueAsBoolean(context, "visible", source.isVisible);
// Save the name, style, and size of the font. These will be used to restore the font using the
// constructor: new Font(name, style, size).
if (source.font != null)
{
RestorableSupport.StateObject fontStateObj = restorableSupport.addStateObject(context, "font");
if (fontStateObj != null)
{
restorableSupport.addStateValueAsString(fontStateObj, "name", source.font.getName());
restorableSupport.addStateValueAsInteger(fontStateObj, "style", source.font.getStyle());
restorableSupport.addStateValueAsInteger(fontStateObj, "size", source.font.getSize());
}
}
if (source.textAlign >= 0)
restorableSupport.addStateValueAsInteger(context, "textAlign", source.textAlign);
if (source.textColor != null)
{
String encodedColor = RestorableSupport.encodeColor(source.textColor);
if (encodedColor != null)
restorableSupport.addStateValueAsString(context, "textColor", encodedColor);
}
if (source.backgroundColor != null)
{
String encodedColor = RestorableSupport.encodeColor(source.backgroundColor);
if (encodedColor != null)
restorableSupport.addStateValueAsString(context, "backgroundColor", encodedColor);
}
if (source.borderColor != null)
{
String encodedColor = RestorableSupport.encodeColor(source.borderColor);
if (encodedColor != null)
restorableSupport.addStateValueAsString(context, "borderColor", encodedColor);
}
// Save the imagePath property only when the imageSource property is a simple String path. If the imageSource
// property is a BufferedImage (or some other object), we make no effort to save that state. We save under
// the name "imagePath" to denote that it is a special case of "imageSource".
if (source.getPath() != null)
restorableSupport.addStateValueAsString(context, "imagePath", source.getPath(), true);
if (source.imageScale >= 0)
restorableSupport.addStateValueAsDouble(context, "imageScale", source.imageScale);
if (source.imageOffset != null)
{
RestorableSupport.StateObject imageOffsetStateObj =
restorableSupport.addStateObject(context, "imageOffset");
if (imageOffsetStateObj != null)
{
restorableSupport.addStateValueAsDouble(imageOffsetStateObj, "x", source.imageOffset.getX());
restorableSupport.addStateValueAsDouble(imageOffsetStateObj, "y", source.imageOffset.getY());
}
}
if (source.imageOpacity >= 0)
restorableSupport.addStateValueAsDouble(context, "imageOpacity", source.imageOpacity);
if (source.imageRepeat != null)
restorableSupport.addStateValueAsString(context, "imageRepeat", source.imageRepeat);
if (source.distanceMinScale >= 0)
restorableSupport.addStateValueAsDouble(context, "distanceMinScale", source.distanceMinScale);
if (source.distanceMaxScale >= 0)
restorableSupport.addStateValueAsDouble(context, "distanceMaxScale", source.distanceMaxScale);
if (source.distanceMinOpacity >= 0)
restorableSupport.addStateValueAsDouble(context, "distanceMinOpacity", source.distanceMinOpacity);
if (source.effect != null)
restorableSupport.addStateValueAsString(context, "effect", source.effect);
}
/**
* Restores the any attributes appearing in the specified <code>restorableSupport</code>. If <code>context</code>
* is not null, this will search for attributes beneath it. Otherwise, this will search for attributes
* beneath the document root.
*
* @param restorableSupport RestorableSupport to read attribute values from.
* @param context RestorableSupport.StateObject under which attributes will be looked, if not null.
* @param dest the AnnotationAttributes to restore.
* @throws IllegalArgumentException If either <code>restorableSupport</code> or <code>dest</code> is null.
*/
private static void restoreAttributes(RestorableSupport restorableSupport,
RestorableSupport.StateObject context,
AnnotationAttributes dest)
{
if (restorableSupport == null || dest == null)
throw new IllegalArgumentException();
String frameShapeState = restorableSupport.getStateValueAsString(context, "frameShape");
if (frameShapeState != null)
dest.setFrameShape(frameShapeState);
Boolean highlightedState = restorableSupport.getStateValueAsBoolean(context, "highlighted");
if (highlightedState != null)
dest.setHighlighted(highlightedState);
Double highlightScaleState = restorableSupport.getStateValueAsDouble(context, "highlightScale");
if (highlightScaleState != null)
dest.setHighlightScale(highlightScaleState);
// Restore the size property only if all parts are available.
// We will not restore a partial size (for example, just the width).
RestorableSupport.StateObject sizeStateObj = restorableSupport.getStateObject(context, "size");
if (sizeStateObj != null)
{
Double widthState = restorableSupport.getStateValueAsDouble(sizeStateObj, "width");
Double heightState = restorableSupport.getStateValueAsDouble(sizeStateObj, "height");
if (widthState != null && heightState != null)
dest.setSize(new Dimension(widthState.intValue(), heightState.intValue()));
}
Double scaleState = restorableSupport.getStateValueAsDouble(context, "scale");
if (scaleState != null)
dest.setScale(scaleState);
Double opacityState = restorableSupport.getStateValueAsDouble(context, "opacity");
if (opacityState != null)
dest.setOpacity(opacityState);
String leaderState = restorableSupport.getStateValueAsString(context, "leader");
if (leaderState != null)
dest.setLeader(leaderState);
Integer cornerRadiusState = restorableSupport.getStateValueAsInteger(context, "cornerRadius");
if (cornerRadiusState != null)
dest.setCornerRadius(cornerRadiusState);
String adjustWidthToTextState = restorableSupport.getStateValueAsString(context, "adjustWidthToText");
if (adjustWidthToTextState != null)
dest.setAdjustWidthToText(adjustWidthToTextState);
// Restore the drawOffset property only if all parts are available.
// We will not restore a partial drawOffset (for example, just the x value).
RestorableSupport.StateObject drawOffsetStateObj = restorableSupport.getStateObject(context, "drawOffset");
if (drawOffsetStateObj != null)
{
Double xState = restorableSupport.getStateValueAsDouble(drawOffsetStateObj, "x");
Double yState = restorableSupport.getStateValueAsDouble(drawOffsetStateObj, "y");
if (xState != null && yState != null)
dest.setDrawOffset(new Point(xState.intValue(), yState.intValue()));
}
// Restore the insets property only if all parts are available.
// We will not restore a partial insets (for example, just the top value).
RestorableSupport.StateObject insetsStateObj = restorableSupport.getStateObject(context, "insets");
if (insetsStateObj != null)
{
Integer topState = restorableSupport.getStateValueAsInteger(insetsStateObj, "top");
Integer leftState = restorableSupport.getStateValueAsInteger(insetsStateObj, "left");
Integer bottomState = restorableSupport.getStateValueAsInteger(insetsStateObj, "bottom");
Integer rightState = restorableSupport.getStateValueAsInteger(insetsStateObj, "right");
if (topState != null && leftState != null && bottomState != null && rightState != null)
dest.setInsets(new Insets(topState, leftState, bottomState, rightState));
}
Double borderWidthState = restorableSupport.getStateValueAsDouble(context, "borderWidth");
if (borderWidthState != null)
dest.setBorderWidth(borderWidthState);
Integer borderStippleFactorState = restorableSupport.getStateValueAsInteger(context, "borderStippleFactor");
if (borderStippleFactorState != null)
dest.setBorderStippleFactor(borderStippleFactorState);
Integer borderStipplePatternState = restorableSupport.getStateValueAsInteger(context, "borderStipplePattern");
if (borderStipplePatternState != null)
dest.setBorderStipplePattern(borderStipplePatternState.shortValue());
Integer antiAliasHintState = restorableSupport.getStateValueAsInteger(context, "antiAliasHint");
if (antiAliasHintState != null)
dest.setAntiAliasHint(antiAliasHintState);
Boolean visibleState = restorableSupport.getStateValueAsBoolean(context, "visible");
if (visibleState != null)
dest.setVisible(visibleState);
// Restore the font property only if all parts are available.
// We will not restore a partial font (for example, just the size).
RestorableSupport.StateObject fontStateObj = restorableSupport.getStateObject(context, "font");
if (fontStateObj != null)
{
// The "font name" of toolTipFont.
String nameState = restorableSupport.getStateValueAsString(fontStateObj, "name");
// The style attributes.
Integer styleState = restorableSupport.getStateValueAsInteger(fontStateObj, "style");
// The simple font size.
Integer sizeState = restorableSupport.getStateValueAsInteger(fontStateObj, "size");
if (nameState != null && styleState != null && sizeState != null)
dest.setFont(new Font(nameState, styleState, sizeState));
}
Integer textAlignState = restorableSupport.getStateValueAsInteger(context, "textAlign");
if (textAlignState != null)
dest.setTextAlign(textAlignState);
String textColorState = restorableSupport.getStateValueAsString(context, "textColor");
if (textColorState != null)
{
Color color = RestorableSupport.decodeColor(textColorState);
if (color != null)
dest.setTextColor(color);
}
String backgroundColorState = restorableSupport.getStateValueAsString(context, "backgroundColor");
if (backgroundColorState != null)
{
Color color = RestorableSupport.decodeColor(backgroundColorState);
if (color != null)
dest.setBackgroundColor(color);
}
String borderColorState = restorableSupport.getStateValueAsString(context, "borderColor");
if (borderColorState != null)
{
Color color = RestorableSupport.decodeColor(borderColorState);
if (color != null)
dest.setBorderColor(color);
}
// The imagePath property should exist only if the imageSource property was a simple String path.
// If the imageSource property was a BufferedImage (or some other object), it should not exist in the
// state document. We save under the name "imagePath" to denote that it is a special case of "imageSource".
String imagePathState = restorableSupport.getStateValueAsString(context, "imagePath");
if (imagePathState != null)
dest.setImageSource(imagePathState);
Double imageScaleState = restorableSupport.getStateValueAsDouble(context, "imageScale");
if (imageScaleState != null)
dest.setImageScale(imageScaleState);
// Restore the imageOffset property only if all parts are available.
// We will not restore a partial imageOffset (for example, just the x value).
RestorableSupport.StateObject imageOffsetStateObj = restorableSupport.getStateObject(context, "imageOffset");
if (imageOffsetStateObj != null)
{
Double xState = restorableSupport.getStateValueAsDouble(imageOffsetStateObj, "x");
Double yState = restorableSupport.getStateValueAsDouble(imageOffsetStateObj, "y");
if (xState != null && yState != null)
dest.setImageOffset(new Point(xState.intValue(), yState.intValue()));
}
Double imageOpacityState = restorableSupport.getStateValueAsDouble(context, "imageOpacity");
if (imageOpacityState != null)
dest.setImageOpacity(imageOpacityState);
String imageRepeatState = restorableSupport.getStateValueAsString(context, "imageRepeat");
if (imageRepeatState != null)
dest.setImageRepeat(imageRepeatState);
Double distanceMinScaleState = restorableSupport.getStateValueAsDouble(context, "distanceMinScale");
if (distanceMinScaleState != null)
dest.setDistanceMinScale(distanceMinScaleState);
Double distanceMaxScaleState = restorableSupport.getStateValueAsDouble(context, "distanceMaxScale");
if (distanceMaxScaleState != null)
dest.setDistanceMaxScale(distanceMaxScaleState);
Double distanceMinOpacityState = restorableSupport.getStateValueAsDouble(context, "distanceMinOpacity");
if (distanceMinOpacityState != null)
dest.setDistanceMinOpacity(distanceMinOpacityState);
String effectState = restorableSupport.getStateValueAsString(context, "effect");
if (effectState != null)
dest.setEffect(effectState);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -