CadOptions

Contents
[ ]

Inheritance: java.lang.Object

public class CadOptions

Provides options for rendering CAD drawings.

The CadOptions class encapsulates various settings and parameters that can be used to control the rendering of CAD drawings in the GroupDocs.Viewer component.

Example usage:


 CadOptions options = CadOptions.forRenderingByWidth(256);
 options.setRenderLayouts(true);
 options.setBackgroundColor(Color.YELLOW);
 options.setLayers(Arrays.asList(
         CacheableFactory.getInstance().newLayer("Layer1"),
         CacheableFactory.getInstance().newLayer("Layer2")
 ));

 try (Viewer viewer = new Viewer("document.dwg")) {
     PdfViewOptions pdfViewOptions = new PdfViewOptions();
     pdfViewOptions.setCadOptions(options);
     viewer.view(pdfViewOptions);
     // Use the viewer object for further operations
 }
 

Fields

Field Description
WIDTH
HEIGHT

Methods

Method Description
getPc3File() Retrieves the PC3 (Plotter Configuration) file associated with the plotter.
setPc3File(String pc3File) Sets the PC3 (Plotter Configuration) file associated with the plotter.
forRenderingByScaleFactor(float scaleFactor) Initializes a new instance of the CadOptions class for rendering by scale factor.
forRenderingByWidth(int width) Initializes a new instance of the CadOptions class for rendering by width.
forRenderingByHeight(int height) Initializes a new instance of the CadOptions class for rendering by height.
forRenderingByWidthAndHeight(int width, int height) Initializes a new instance of the CadOptions class for rendering by width and height.
getScaleFactor() Gets the scale factor for rendering.
getWidth() Gets the width of the output result in pixels.
getHeight() Gets the height of the output result in pixels.
getBackgroundColor() Gets the background color of the image.
getBackgroundColorAsHex() Gets the background color of the image.
setBackgroundColor(Color backgroundColor) Sets the background color of the image.
setBackgroundColor(String colorName) Sets the background color of the image.
getTiles() Gets the drawing regions to render.
setTiles(List value) Sets the drawing regions to render.
isRenderLayouts() Indicates whether layouts from the CAD document should be rendered.
setRenderLayouts(boolean value) Sets whether layouts from the CAD document should be rendered.
getLayoutName() Gets the name of the specific layout to render.
setLayoutName(String value) Sets the name of the specific layout to render.
getLayers() Gets the CAD drawing layers to render.
setLayers(List value) Gets the CAD drawing layers to render.
equals(Object o) Checks if this CadOptions object is equal to another object.
hashCode() {@inheritDoc}
toString() {@inheritDoc}
toString(ToStringStyle style) {@inheritDoc}

WIDTH

public static final String WIDTH

HEIGHT

public static final String HEIGHT

getPc3File()

public String getPc3File()

Retrieves the PC3 (Plotter Configuration) file associated with the plotter.

Returns: java.lang.String - the PC3 file path.

setPc3File(String pc3File)

public void setPc3File(String pc3File)

Sets the PC3 (Plotter Configuration) file associated with the plotter.

Parameters:

Parameter Type Description
pc3File java.lang.String The PC3 file path.

forRenderingByScaleFactor(float scaleFactor)

public static CadOptions forRenderingByScaleFactor(float scaleFactor)

Initializes a new instance of the CadOptions class for rendering by scale factor.

Parameters:

Parameter Type Description
scaleFactor float The scale factor for rendering. Values greater than 1 will enlarge the output result, while values between 0 and 1 will make the output result smaller.

Returns: CadOptions - a new instance of the CadOptions class for rendering by scale factor.

forRenderingByWidth(int width)

public static CadOptions forRenderingByWidth(int width)

Initializes a new instance of the CadOptions class for rendering by width.

Parameters:

Parameter Type Description
width int The width of the output result in pixels.

Returns: CadOptions - a new instance of the CadOptions class for rendering by width.

forRenderingByHeight(int height)

public static CadOptions forRenderingByHeight(int height)

Initializes a new instance of the CadOptions class for rendering by height.

Parameters:

Parameter Type Description
height int The height of the output result in pixels.

Returns: CadOptions - a new instance of the CadOptions class for rendering by height.

forRenderingByWidthAndHeight(int width, int height)

public static CadOptions forRenderingByWidthAndHeight(int width, int height)

Initializes a new instance of the CadOptions class for rendering by width and height.

Parameters:

Parameter Type Description
width int The width of the output result in pixels.
height int The height of the output result in pixels.

Returns: CadOptions - a new instance of the CadOptions class for rendering by width and height.

getScaleFactor()

public final float getScaleFactor()

Gets the scale factor for rendering. Values higher than 1 will enlarge the output result, while values between 0 and 1 will make the output result smaller.

Returns: float - the scale factor for rendering.

getWidth()

public final int getWidth()

Gets the width of the output result in pixels.

Returns: int - the width of the output result.

getHeight()

public final int getHeight()

Gets the height of the output result in pixels.

Returns: int - the height of the output result.

getBackgroundColor()

public Color getBackgroundColor()

Gets the background color of the image.

Returns: java.awt.Color - the background color of the image.

getBackgroundColorAsHex()

public String getBackgroundColorAsHex()

Gets the background color of the image.

Returns: java.lang.String - the background color of the image in 0xFFFFFF format.

setBackgroundColor(Color backgroundColor)

public void setBackgroundColor(Color backgroundColor)

Sets the background color of the image.

Parameters:

Parameter Type Description
backgroundColor java.awt.Color The background color of the image.

setBackgroundColor(String colorName)

public void setBackgroundColor(String colorName)

Sets the background color of the image.

Parameters:

Parameter Type Description
colorName java.lang.String The background color name of the image.

getTiles()

public final List<Tile> getTiles()

Gets the drawing regions to render.

Note: This option is supported only for FileType.DWG and FileType.DWT file types. The RenderLayouts (isRenderLayouts()/setRenderLayouts(boolean)) and LayoutName (getLayoutName()/setLayoutName(String)) options are ignored when rendering by tiles.

Returns: java.util.List<com.groupdocs.viewer.options.Tile> - the list of drawing regions to render.

setTiles(List value)

public final void setTiles(List<Tile> value)

Sets the drawing regions to render.

Note: This option is supported only for FileType.DWG and FileType.DWT file types. The RenderLayouts (isRenderLayouts()/setRenderLayouts(boolean)) and LayoutName (getLayoutName()/setLayoutName(String)) options are ignored when rendering by tiles.

Parameters:

Parameter Type Description
value java.util.List<com.groupdocs.viewer.options.Tile> The list of drawing regions to render.

isRenderLayouts()

public final boolean isRenderLayouts()

Indicates whether layouts from the CAD document should be rendered.

Note: This option applies only to CAD drawings that support layouts, such as FileType.DXF, FileType.DWG, FileType.DWT, FileType.DWF, and FileType.DWFX. By default, only the Model is rendered.

Returns: boolean - true if layouts should be rendered, false otherwise.

setRenderLayouts(boolean value)

public final void setRenderLayouts(boolean value)

Sets whether layouts from the CAD document should be rendered.

Note: This option applies only to CAD drawings that support layouts, such as FileType.DXF, FileType.DWG, FileType.DWT, FileType.DWF, and FileType.DWFX. By default, only the Model is rendered.

Parameters:

Parameter Type Description
value boolean true to render layouts, false otherwise.

getLayoutName()

public final String getLayoutName()

Gets the name of the specific layout to render. The layout name is case-sensitive.

Note: This option applies only to CAD drawings that support layouts, such as FileType.DXF, FileType.DWG, FileType.DWT, FileType.DWF, and FileType.DWFX. By default, only the Model is rendered.

Returns: java.lang.String - the name of the specific layout to render.

setLayoutName(String value)

public final void setLayoutName(String value)

Sets the name of the specific layout to render. The layout name is case-sensitive.

Note: This option applies only to CAD drawings that support layouts, such as FileType.DXF, FileType.DWG, FileType.DWT, FileType.DWF, and FileType.DWFX. By default, only the Model is rendered.

Parameters:

Parameter Type Description
value java.lang.String The name of the specific layout to render.

getLayers()

public final List<Layer> getLayers()

Gets the CAD drawing layers to render.

Note: By default, all layers are rendered. Layer names are case-sensitive.

Returns: java.util.List<com.groupdocs.viewer.results.Layer> - the CAD drawing layers.

setLayers(List value)

public final void setLayers(List<Layer> value)

Gets the CAD drawing layers to render.

Note: By default, all layers are rendered. Layer names are case-sensitive.

Parameters:

Parameter Type Description
value java.util.List<com.groupdocs.viewer.results.Layer> The CAD drawing layers.

equals(Object o)

public boolean equals(Object o)

Checks if this CadOptions object is equal to another object.

Parameters:

Parameter Type Description
o java.lang.Object The object to compare with.

Returns: boolean - true if the objects are equal, false otherwise.

hashCode()

public int hashCode()

Computes the hash code value for this object. The hash code is based on the internal state of the object and is used in hash-based data structures such as hash maps and hash sets.

Note: This method overrides the default implementation of the hashCode() method defined in the Object class.

Returns: int - the hash code value for this object.

toString()

public String toString()

Returns a string representation of this object.

Note: This method overrides the default implementation of the toString() method defined in the Object class.

Returns: java.lang.String - a string representation of this object.

toString(ToStringStyle style)

public String toString(ToStringStyle style)

Returns a string representation of this object.

Note: This method overrides the default implementation of the toString() method defined in the Object class.

Parameters:

Parameter Type Description
style org.apache.commons.lang3.builder.ToStringStyle The ToStringStyle to use for generating the string representation.

Returns: java.lang.String - a string representation of this object using the specified ToStringStyle.