Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER Copyright 2011 IBM. All rights reserved. Use is subject to license terms. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. You can also obtain a copy of the License at http://odftoolkit.org/docs/license.txt Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 
 package org.odftoolkit.simple.style;
 
This class represents the graphic style settings. It provides methods to access borders and background styles. More functions will be added later.

This class is a corresponded high level class for element "style:graphic-properties". It provides methods to access the attributes and children of "style:graphic-properties".

Since:
0.5
 
 public class GraphicProperties {
 
Create a paragraph style setting object, which has the association with an element "style:paragraph-properties".

Parameters:
properties - the element "style:paragraph-properties"
 
 		 = properties;
 	}

Return an instance of GraphicProperties to represent the "style:graphic-properties" in a style element.

If there is no "style:graphic-properties" defined in the style element, a new "style:graphic-properties" element will be created.

Parameters:
style - a style element
Returns:
an instance of GraphicProperties
 
 		return new GraphicProperties((StyleGraphicPropertiesElementproperties);
 	}

Return an instance of GraphicProperties to represent the "style:graphic-properties" in a style element.

If there is no "style:graphic-properties" defined in the style element, null will be returned.

Parameters:
style - a style element
Returns:
an instance of GraphicProperties;Null if there is no "style:graphic-properties" defined
		if (properties != null)
		else
			return null;
	}

Set the border style.

The first parameter bordersType describes which borders you want to apply the style to, e.g. up border, bottom border, left border, right border, diagonal lines or four borders.

The border style information will be removed if the parameter bordersType is NONE.

Parameters:
bordersType - the type of the borders
border - the border style description
	public void setBorders(StyleTypeDefinitions.CellBordersType bordersTypeBorder border) {
		switch (bordersType) {
		case :
			break;
		case :
			break;
		case :
			break;
		case :
			setTopBorder(border);
			break;
			throw new RuntimeException("DIAGONALBL is not supported");
			throw new RuntimeException("DIAGONALTLBR is not supported");
		case :
			setBorder(border);
			break;
			// border.switchInnerLineOuterLineWidth();
			break;
			setTopBorder(border);
			// border.switchInnerLineOuterLineWidth();
			break;
			throw new RuntimeException("DIAGONAL_LINES is not supported");
		case :
		}
	}

Return the border setting for all four borders.

Null will be returned if there is no border setting for all four borders.

Returns:
the border setting
	public Border getBorder() {
	}

Return the border setting for the top border.

Null will be returned if there is no border setting for the top border.

Returns:
the border setting
	public Border getTopBorder() {
	}

Return the border setting for the left border.

Null will be returned if there is no border setting for the left border.

Returns:
the border setting
	public Border getLeftBorder() {
	}

Return the border setting for the right border.

Null will be returned if there is no border setting for the right border.

Returns:
the border setting
	public Border getRightBorder() {
	}
	// fo:border-bottom
	// style:border-line-width-bottom
Return the border setting for the bottom border.

Null will be returned if there is no border setting for the bottom border.

Returns:
the border setting
	public Border getBottomBorder() {
	}
	// fo:border-bottom
	// style:border-line-width-bottom
Set the border definition for the bottom border.

If the parameter border is null, the border definition for the bottom border will be removed.

If the line type in the border definition is NONE, the border definition for the bottom border will be removed.

Parameters:
border - the border setting
	public void setBottomBorder(Border border) {
	}
	// fo:border-top
	// style:border-line-width-top
Set the border definition for the top border.

If the parameter border is null, the border definition for the top border will be removed.

If the line type in the border definition is NONE, the border definition for the top border will be removed.

Parameters:
border - the border setting
	public void setTopBorder(Border border) {
	}
	// fo:border-left
	// style:border-line-width-left
Set the border definition for the left border.

If the parameter border is null, the border definition for the left border will be removed.

If the line type in the border definition is NONE, the border definition for the left border will be removed.

Parameters:
border - the border setting
	public void setLeftBorder(Border border) {
	}
	// fo:border-right
	// style:border-line-width-right
Set the border definition for the right border.

If the parameter border is null, the border definition for the right border will be removed.

If the line type in the border definition is NONE, the border definition for the right border will be removed.

Parameters:
border - the border setting
	public void setRightBorder(Border border) {
	}
	// fo:border
	// style:border-line-width
Set the border definition for all four borders.

If the parameter border is null, the border definition for all four borders will be removed.

If the line type in the border definition is NONE, the border definition for all four borders will be removed.

Parameters:
border - the border setting
	public void setBorder(Border border) {
	}

Set the style of stroke.

There are three types of stroke: none, solid and dash.

If the stroke is NONE, there is no stroke around the frame.

If the stroke is SOLID, there is solid line around the frame. color and width need to be specified.

If the stroke is DASH, there is dash line around the frame. color, width and the style name of dash line need to be specified.

Parameters:
stroke the stroke type
color the color of the stroke
widthDesc the width description of the stroke, e.g. "0.01in"
dashStyleName the dash style name
See also:
StyleTypeDefinitions.OdfDrawStroke
	public void setStroke(OdfDrawStroke strokeColor colorString widthDescString dashStyleName) {
		switch (stroke) {
		case :
			break;
		case :
			if (color != null)
			if (widthDesc != null && widthDesc.length() > 2 && verifyWidthDesc(widthDesc)) {
			}
			break;
		case :
			if (color != null)
			if (widthDesc != null && widthDesc.length() > 2 && verifyWidthDesc(widthDesc)) {
			}
		}
	}

Set the fill style for a graphic object.

This method supports 2 types of fill: none and solid.

If the fill type is NONE, the object is no filled at all.

If the fill type is SOLID, the drawing object is filled with the color specified by the second parameter.

Parameters:
fillType the fill style type
color the specified color
	public void setFill(OdfDrawFill fillTypeColor color) {
		switch (fillType) {
		case :
			break;
		case :
			break;
		case :
		case :
		case :
			throw new RuntimeException(fillType.toString() + " not supported!");
		}
	}

Set whether the content of a graphic object is displayed in the background or foreground. If it's displayed in the background, the content wouldn't be selected or moved.

Parameters:
isBackgroundObject If true, the graphic object is displayed in the background.
Since:
0.5.5
	public void setStyleRunThrough(boolean isBackgroundObject) {
		if (isBackgroundObject) {
else {
		}
	}

Set the horizontal position

Parameters:
horizontalPos the horizontal position
Since:
0.5.5
	public void setHorizontalPosition(FrameHorizontalPosition horizontalPos) {
	}

Set the horizontal relative

Parameters:
relative the horizontal relative
Since:
0.5.5
	public void setHorizontalRelative(HorizontalRelative relative) {
	}

Set the vertical relative

Parameters:
relative the vertical relative
Since:
0.5.5
	public void setVerticalRelative(VerticalRelative relative) {
	}

Set the vertical position

Parameters:
verticalPos the vertical position
Since:
0.5.5
	public void setVerticalPosition(FrameVerticalPosition verticalPos) {
	}

Return the horizontal position

Returns:
the horizontal position
Since:
0.5.5
		return FrameHorizontalPosition.enumValueOf(.getStyleHorizontalPosAttribute());
	}

Return the vertical position

Returns:
the vertical position
Since:
0.5.5
		return FrameVerticalPosition.enumValueOf(.getStyleVerticalPosAttribute());
	}

Return the vertical relative

Returns:
the vertical relative
Since:
0.5.5
	}

Return the horizontal relative

Returns:
the horizontal relative
Since:
0.5.5
	}
	private boolean verifyWidthDesc(String widthDesc) {
		char char1 = widthDesc.charAt(widthDesc.length() - 1);
		char char2 = widthDesc.charAt(widthDesc.length() - 2);
		if (!(char1 >= 'a' && char1 <= 'z') && !(char1 >= 'A' && (char1 <= 'Z')))
			return false;
		if (!(char2 >= 'a' && char2 <= 'z') && !(char2 >= 'A' && (char2 <= 'Z')))
			return false;
		String floatValue = widthDesc.substring(0, widthDesc.length() - 2).trim();
		try {
			Double.parseDouble(floatValue);
catch (Exception e) {
			return false;
		}
		return true;
	}
New to GrepCode? Check out our FAQ X