General Drawing Properties
This chapter introduces the relevant drawing attributes provided by services, such as com.sun.star.drawing.LineProperties, com.sun.star.drawing.FillProperties and com.sun.star.drawing.TextProperties. The service is described by listing all its properties, followed by an example that uses and explains some of the properties. Each of the following Java examples assumes an already existing valid shape xShape
that has already been inserted into the page.
Colors are given in Hex ARGB format, a four-byte value containing the alpha, red, green and blue components of a color in the format 0xAARRGGBB. The leading component can be omitted if it is zero. The hex format 0xFF0000 is light red, 0xFF00 is green, and 0xFF is blue.
Angles must be given in steps of 1/100th of a degree.
Measures, such as line widths and lengths are given in 100th of a millimeter.
Properties provided by the service :
Properties of com.sun.star.drawing.LineProperties | |
---|---|
LineStyle | com.sun.star.drawing.LineStyle. This enumeration selects the style of the line. |
LineDash | com.sun.star.drawing.LineDash. This enumeration selects the dash of the line |
LineColor | long - Color of the line.
|
LineTransparence | short - Degree of transparency.
|
LineWidth | long - Width of the line in 1/100th of a millimeter.
|
LineJoint | com.sun.star.drawing.LineJoint. Rendering of joints between thick lines. |
LineStartName | [optional] string - Name of the line that starts poly polygon bezier.
|
LineStart | [optional] com.sun.star.drawing.PolyPolygonBezierCoords. Line starts in the form of a poly polygon bezier.
|
LineEnd | [optional] com.sun.star.drawing.PolyPolygonBezierCoords. Line ends in the form of a poly polygon bezier.
|
LineStartCenter | [optional] boolean - If true, the line starts from the center of the polygon.
|
LineStartWidth | [optional] long - Width of the line start polygon. |
LineEndCenter | [optional] boolean - If true, the line ends in the center of the polygon.
|
LineEndWidth | [optional] long - Width of the line end polygon.
|
/* create a blue line with dashes and dots */
XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, xShape );
xPropSet.setPropertyValue( "LineStyle", LineStyle.DASH );
LineDash aLineDash = new LineDash();
aLineDash.Dots = 3;
aLineDash.DotLen = 150;
aLineDash.Dashes = 3;
aLineDash.DashLen = 300;
aLineDash.Distance = 150;
xPropSet.setPropertyValue( "LineDash", aLineDash );
xPropSet.setPropertyValue( "LineColor", new Integer( 0x0000ff ) );
xPropSet.setPropertyValue( "LineWidth", new Integer( 200 ) );
Properties of com.sun.star.drawing.FillProperties | |
---|---|
FillStyle | com.sun.star.drawing.FillStyle. This enumeration selects the style that the area is filled with. |
FillColor | long - If the FillStyle is set to SOLID , this is the color used.
|
FillTransparence | short - The transparency of the filled area in percent.
|
FillTransparenceGradientName | string - This is the name of the transparent gradient style used if a gradient is used for transparency, or it is empty. This style is used to set the name of a transparent gradient style contained in the document.
|
FillTransparenceGradient | [optional] com.sun.star.awt.Gradient. Transparency of the fill area as a gradient.
|
FillGradientName | string - If the FillStyle is set to GRADIENT , this is the name of the fill gradient style used.
|
FillGradient | [optional] com.sun.star.awt.Gradient. If the FillStyle is set to GRADIENT , this describes the gradient used.
|
FillHatchName | string - If the FillStyle is set to GRADIENT , this is the name of the fill hatch style used.
|
FillHatch | [optional] com.sun.star.drawing.Hatch. If the FillStyle is set to HATCH , this describes the hatch used.
|
FillBitmapName | string - If the FillStyle is set to BITMAP , this is the name of the fill bitmap style used.
|
FillBitmap | [optional] com.sun.star.awt.XBitmap. If the FillStyle is set to BITMAP , this is the bitmap used.
|
FillBitmapURL | [optional] string . If the FillStyle is set to BITMAP , this is a URL to the bitmap used.
|
FillBitmapOffsetX | short - Horizontal offset where the tile starts.
|
FillBitmapOffsetY | short - Vertical offset where the tile starts. It is given in percent in relation to the width of the bitmap.
|
FillBitmapPositionOffsetX | short - Every second line of tiles is moved the given percent of the width of the bitmap.
|
FillBitmapPositionOffsetY | short - Every second row of tiles is moved the given percent of the width of the bitmap.
|
FillBitmapRectanglePoint | com.sun.star.drawing.RectanglePoint. The RectanglePoint specifies the position inside of the bitmap to use as the top-left position for rendering.
|
FillBitmapLogicalSize | boolean - Specifies if the size is given in percentage or as an absolute value.
|
FillBitmapSizeX | long - Width of the tile for filling.
|
FillBitmapSizeY | long - Height of the tile for filling.
|
FillBitmapMode | com.sun.star.drawing.BitmapMode. Enumeration selects how an area is filled with a single bitmap. |
FillBackground | boolean - If true , the transparent background of a hatch filled area is drawn in the current background color.
|
/* apply a gradient fill style that goes from top left to bottom
right and is changing its color from green to yellow */
XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, xShape );
xPropSet.setPropertyValue( "FillStyle", FillStyle.GRADIENT );
Gradient aGradient = new Gradient();
aGradient.Style = GradientStyle.LINEAR;
aGradient.StartColor = 0x00ff00;
aGradient.EndColor = 0xffff00;
aGradient.Angle = 450;
aGradient.Border = 0;
aGradient.XOffset = 0;
aGradient.YOffset = 0;
aGradient.StartIntensity = 100;
aGradient.EndIntensity = 100;
aGradient.StepCount = 10;
xPropSet.setPropertyValue( "FillGradient", aGradient );
Properties of com.sun.star.drawing.TextProperties | |
---|---|
IsNumbering | [optional] boolean - If true, numbering is on for the text of this shape.
|
NumberingRules | [optional] com.sun.star.container.XIndexReplace. Describes the numbering levels.
|
TextAutoGrowHeight | boolean - If true, the height of the shape is automatically expanded or shrunk when text is added or removed from the shape.
|
TextAutoGrowWidth | boolean - If true, the width of the shape is automatically expanded or shrunk when text is added or removed from the shape.
|
TextContourFrame | boolean - If true, the left edge of every line of text is aligned with the left edge of this shape.
|
TextFitToSize | com.sun.star.drawing.TextFitToSizeType. Determines how the text inside of the Shape is stretched to fit in the Shape . Possible values are NONE , PROPORTIONAL , ALLLINES , and RESIZEATTR .
|
TextHorizontalAdjust | com.sun.star.drawing.TextHorizontalAdjust. Adjusts the horizontal position of the text inside of the shape. |
TextVerticalAdjust | com.sun.star.drawing.TextVerticalAdjust. Adjusts the vertical position of the text inside of the shape. |
TextLeftDistance | long - Distance from the left edge of the shape to the left edge of the text.
|
TextRightDistance | long - Distance from the right edge of the shape to the right edge of the text.
|
TextUpperDistance | long - Distance from the upper edge of the shape to the upper edge of the text.
|
TextLowerDistance | long - Distance from the lower edge of the shape to the lower edge of the text.
|
TextMaximumFrameHeight | long - Maximum height of the surrounding frame.
|
TextMaximumFrameWidth | long - Maximum width of the surrounding frame.
|
TextMinimumFrameHeight | long - Minimum height of the surrounding frame.
|
TextMinimumFrameWidth | long - Minimum width of the surrounding frame.
|
TextAnimationAmount | short - Number of pixels that the text is moved in each animation step.
|
TextAnimationCount | short - Defines how many times the text animation is repeated.
|
TextAnimationDelay | short - Delay between the animation steps in thousandths of a second.
|
TextAnimationDirection | com.sun.star.drawing.TextAnimationDirection. This enumeration defines the direction that the text moves. |
TextAnimationKind | com.sun.star.drawing.TextAnimationKind. Defines the type of animation. |
TextAnimationStartInside | boolean . If true, the text is visible at the start of the animation.
|
TextAnimationStopInside | boolean . If true, the text is visible at the end of the animation.
|
TextWritingMode | com.sun.star.text.WritingMode. This value selects the writing mode for the text. |
The service com.sun.star.drawing.TextProperties includes com.sun.star.style.ParagraphProperties and com.sun.star.style.CharacterProperties. Since these services contain optional properties, the properties actually supported by drawing shapes are listed. Refer to the API reference or explanations or Formatting.
The service com.sun.star.drawing.TextProperties includes com.sun.star.style.ParagraphProperties and com.sun.star.style.CharacterProperties. Since these services contain many optional properties, we list the properties actually supported by drawing shapes. Please look up the explanations in the API reference or in Formatting.
com.sun.star.style.CharacterProperties of drawing text | |
---|---|
CharAutoKerning | boolean
|
CharColor | long
|
CharContoured | boolean
|
CharCrossedOut | boolean
|
CharEmphasis | short
|
CharEscapement | short
|
CharEscapementHeight | byte
|
CharFontCharSet | short
|
CharFontFamily | short
|
CharFontName | string
|
CharFontPitch | short
|
CharFontStyleName | string
|
CharHeight | float
|
CharKerning | short
|
CharLocale | com.sun.star.lang.Locale |
CharPosture | com.sun.star.awt.FontSlant |
CharRelief | short
|
CharScaleWidth | short
|
CharShadowed | boolean
|
CharStrikeout | short
|
CharUnderline | short
|
CharUnderlineColor | long
|
CharUnderlineHasColor | boolean
|
CharWeight | float
|
CharWordMode | boolean
|
There are Asian counterparts for a number of character properties.
com.sun.star.style.CharacterPropertiesAsian of drawing shapes | |
---|---|
CharFontPitchAsian | short
|
CharFontStyleNameAsian | string
|
CharHeightAsian | float
|
CharPostureAsian | com.sun.star.awt.FontSlant |
CharLocaleAsian | com.sun.star.lang.Locale |
CharWeightAsian | float
|
There is also a Complex
flavor of the same properties:
Paragraphs in drawing text support a selection of com.sun.star.style.ParagraphProperties:
Properties of com.sun.star.style.ParagraphProperties | |
---|---|
ParaAdjust | short
|
ParaBottomMargin | long
|
ParaFirstLineIndent | long
|
ParaIsHyphenation | boolean
|
ParaLastLineAdjust | short
|
ParaLeftMargin | long
|
ParaLineSpacing | com.sun.star.style.LineSpacing |
ParaRightMargin | long
|
ParaTabStops | sequence <com.sun.star.style.TabStop > |
ParaTopMargin | long
|
ParaUserDefinedAttributes | com.sun.star.uno.XInterface |
And of com.sun.star.style.ParagraphPropertiesAsian:
Properties of com.sun.star.style.ParagraphPropertiesAsian | |
---|---|
ParaIsCharacterDistance | boolean
|
ParaIsForbiddenRules | boolean
|
ParaIsHangingPunctuation | boolean
|
The next example introduces a method that appends single text portions to a shape. It returns the XPropertySet interface of the text range that has been added.
/** add text to a shape.
the return value is the PropertySet of the text range that has been added
*/
public static XPropertySet addPortion(XShape xShape, String sText, boolean bNewParagraph)
throws com.sun.star.lang.IllegalArgumentException {
XText xText = (XText)UnoRuntime.queryInterface(XText.class, xShape);
XTextCursor xTextCursor = xText.createTextCursor();
xTextCursor.gotoEnd(false);
if (bNewParagraph) {
xText.insertControlCharacter(xTextCursor, ControlCharacter.PARAGRAPH_BREAK, false);
xTextCursor.gotoEnd(false);
}
XTextRange xTextRange = (XTextRange)UnoRuntime.queryInterface(XTextRange.class, xTextCursor);
xTextRange.setString(sText);
xTextCursor.gotoEnd(true);
XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextRange);
return xPropSet;
}
Using the previous method, the next example creates a rectangle shape that has a border of 2.5 cm with the text of two paragraphs is stretched by using the com.sun.star.drawing.TextFitToSizeType property. The text of the first paragraph is then colored green, and the second red. The Editing Text provides further details of handling text.
createShape(xComponent, new Point(0,0),
new Size(21000, 12500), "com.sun.star.drawing.RectangleShape");
xShapes.add(xRectangle);
xShapePropSet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xRectangle);
// TextFitToSize
xShapePropSet.setPropertyValue("TextFitToSize", TextFitToSizeType.PROPORTIONAL);
// border size
xShapePropSet.setPropertyValue("TextLeftDistance", new Integer(2500));
xShapePropSet.setPropertyValue("TextRightDistance", new Integer(2500));
xShapePropSet.setPropertyValue("TextUpperDistance", new Integer(2500));
xShapePropSet.setPropertyValue("TextLowerDistance", new Integer(2500));
xTextPropSet = ShapeHelper.addPortion(xRectangle, "using TextFitToSize", false);
xTextPropSet.setPropertyValue("ParaAdjust", ParagraphAdjust.CENTER);
xTextPropSet.setPropertyValue("CharColor", new Integer(0xff00 ));
xTextPropSet = ShapeHelper.addPortion(xRectangle, "and a Border distance of 2,5 cm", true);
xTextPropSet.setPropertyValue("CharColor", new Integer(0xff0000));
Many shapes cast shadows. The ShadowProperties
controls how this shadow looks:
Properties of com.sun.star.drawing.ShadowProperties | |
---|---|
Shadow | boolean - Enables or disables the shadow of a shape.
|
ShadowColor | long - Color of the shadow of the shape.
|
ShadowTransparence | short - Defines the degree of transparency of the shadow in percent.
|
ShadowXDistance | long - Horizontal distance between the left edge of the shape and the shadow.
|
ShadowYDistance | long - Vertical distance between the top edge of the shape and the shadow.
|
Content on this page is licensed under the Public Documentation License (PDL). |