public class Group
extends java.lang.Object
In the simplest case, the group's ON-OFF state makes the associated content visible or hidden. The ON-OFF state of a group can be toggled for a particular context (OCG::Context), and a set of states is kept in a configuration (OCG::Config). The visibility can depend on more than one group in an optional-content membership dictionary (OCG::OCMD), and can also be affected by the context's draw mode (OCGContext::OCDrawMode).
A group has an Intent entry, broadly describing the intended use. A group's content is considered to be optional (that is, the group's state is considered in its visibility) if any intent in its list matches an intent of the context. The intent list of the context is usually set from the intent list of the document configuration.
A Usage dictionary entry provides more specific intended usage information than an intent entry. Possible key values are: CreatorInfo, Language, Export, Zoom, Print, View, User, PageElement. The usage value can act as a kind of metadata, describing the sort of things that belong to the group, such as text in French, fine detail on a map, or a watermark. The usage values can also be used by the AutoState mechanism to make decisions about what groups should be on and what groups should be off. The AutoState mechanism considers the usage information in the OCGs, the AS array of the configuration, and external factors; for example, the language the application is running in, the current zoom level on the page, or whether the page is being printed.
Constructor and Description |
---|
Group(Obj ocg)
Creates a new optional-content group (OCG) object from an existing
SDF/Cos object.
|
Modifier and Type | Method and Description |
---|---|
static Group |
__Create(long impl,
java.lang.Object ref) |
static Group |
create(PDFDoc doc,
java.lang.String name)
Creates a new optional-content group (OCG) object in the document.
|
boolean |
getCurrentState(Context context)
Get the current state of the optional-content group
|
boolean |
getInitialState(Config config)
Get the initial state.
|
Obj |
getIntent()
Get the intent.
|
java.lang.String |
getName()
Get optional-content group
|
Obj |
getSDFObj()
Get the SDFObj.
|
boolean |
hasUsage()
Determine whether Group is associated with a usage dictionary
|
boolean |
isLocked(Config config)
Determine if optional-content group is locked in the given configuration
|
boolean |
isValid()
Determine whether Group is valid
|
void |
setCurrentState(Context context,
boolean state)
Set the current ON-OFF state of the optional-content group (OCG) object in a given context.
|
void |
setInitialState(Config config,
boolean state)
Set the initial state (ON or OFF) of the optional-content group (OCG)
object in a given configuration.
|
void |
setIntent(Obj intent)
Set the Intent entry in an optional-content group's SDF/Cos dictionary.
|
void |
setLocked(Config config,
boolean locked)
Set the locked state of an OCG in a given configuration.
|
void |
setName(java.lang.String name)
Set the name of this optional-content group (OCG).
|
public Group(Obj ocg)
ocg
- the ocgpublic static Group create(PDFDoc doc, java.lang.String name) throws PDFNetException
doc
- The document in which the new OCG will be created.name
- The name of the optional-content group.PDFNetException
public boolean isValid() throws PDFNetException
PDFNetException
public java.lang.String getName() throws PDFNetException
PDFNetException
public void setName(java.lang.String name) throws PDFNetException
name
- The new name.PDFNetException
public boolean getCurrentState(Context context) throws PDFNetException
context
- The context for which to get the group's state.PDFNetException
public void setCurrentState(Context context, boolean state) throws PDFNetException
context
- The context for which to set the group's state.state
- The new state.PDFNetException
public boolean getInitialState(Config config) throws PDFNetException
Note: If the configuration has a BaseState of Unchanged, and the OCG is not listed explicitly in its ON list or OFF list, then the initial state is taken from the OCG's current state in the document's default context.
config
- The configuration for which to get the group's initial state.PDFNetException
public void setInitialState(Config config, boolean state) throws PDFNetException
config
- The configuration for which to set the group's initial state.state
- The new initial state, true if the state is ON, false if it is OFF.PDFNetException
public Obj getIntent() throws PDFNetException
PDFNetException
public void setIntent(Obj intent) throws PDFNetException
intent
- The new Intent entry value (a name object or an array of name objects).PDFNetException
public boolean isLocked(Config config) throws PDFNetException
config
- The OC configuration.PDFNetException
public void setLocked(Config config, boolean locked) throws PDFNetException
config
- IN/OUT The optional-content configuration.locked
- true if the OCG should be locked, false otherwise.PDFNetException
public boolean hasUsage() throws PDFNetException
PDFNetException
public Obj getSDFObj() throws PDFNetException
PDFNetException
public static Group __Create(long impl, java.lang.Object ref)