📄 element.java
字号:
* @return a clone of this element.
*
* @throws CloneNotSupportedException should never happen.
*/
public Object clone() throws CloneNotSupportedException
{
final Element e = (Element) super.clone();
e.style = style.getCopy();
e.datasource = (DataSource) datasource.clone();
e.styleSheetCollectionHelper = new ElementStyleSheetCollectionHelper(e);
return e;
}
/**
* Returns this elements private stylesheet. This sheet can be used to override
* the default values set in one of the parent-stylesheets.
*
* @return the element's stylesheet
*/
public ElementStyleSheet getStyle()
{
return style;
}
/**
* Defines the content-type for this element. The content-type is used as a hint
* how to process the contents of this element. An element implementation should
* restrict itself to the content-type set here, or the reportprocessing may fail
* or the element may not be printed.
* <p>
* An element is not allowed to change its content-type after ther report processing
* has started.
* <p>
* If an content-type is unknown to the output-target, the processor should ignore
* the content or clearly document its internal reprocessing. Ignoring is preferred.
*
* @return the content-type as string.
*/
public abstract String getContentType();
/**
* Returns the stylesheet collection which is assigned with this element and
* all stylesheets of this element.
*
* @return the element stylesheet collection or null, if no collection is assigned.
*/
public StyleSheetCollection getStyleSheetCollection()
{
return styleSheetCollectionHelper.getStyleSheetCollection();
}
/**
* Registers the given StyleSheet collection with this element. If there is already
* another stylesheet collection registered, this method will throw an
* <code>InvalidStyleSheetCollectionException</code>.
*
* @param styleSheetCollection the stylesheet collection that should be registered.
* @throws InvalidStyleSheetCollectionException if there is already an other
* stylesheet registered.
* @throws NullPointerException if the given stylesheet collection is null.
*/
public void registerStyleSheetCollection(final StyleSheetCollection styleSheetCollection)
throws InvalidStyleSheetCollectionException
{
styleSheetCollectionHelper.registerStyleSheetCollection(styleSheetCollection);
}
/**
* Unregisters the given stylesheet collection from this element. If this stylesheet
* collection is not registered with this element, this method will throw an
* <code>InvalidStyleSheetCollectionException</code>
*
* @param styleSheetCollection the stylesheet collection that should be unregistered.
* @throws InvalidStyleSheetCollectionException if there is already an other stylesheet
* registered.
* @throws NullPointerException if the given stylesheet collection is null.
*/
public void unregisterStyleSheetCollection(final StyleSheetCollection styleSheetCollection)
throws InvalidStyleSheetCollectionException
{
styleSheetCollectionHelper.unregisterStyleSheetCollection(styleSheetCollection);
}
/**
* Handles the unregistration of the stylesheet collection.
*/
protected void handleUnregisterStyleSheetCollection()
{
getStyle().unregisterStyleSheetCollection(getStyleSheetCollection());
}
/**
* Handles the registration of the stylesheet collection.
*/
protected void handleRegisterStyleSheetCollection()
{
getStyle().registerStyleSheetCollection(getStyleSheetCollection());
/**
* This is an assertation implementation ... leave it alive to be
* sure that everything works as expected ...
*/
if (getStyle().getStyleSheetCollection() != getStyleSheetCollection())
{
throw new IllegalStateException("HandleRegisterStyleSheetCollection failed: " +
getStyle().getName() + " for element " + getName());
}
}
/**
* Updates the stylesheet collection for this element and all substylesheets.
* This method must be called after the element was cloned, to make sure that
* all stylesheets are registered properly.
* <p>
* If you don't call this function after cloning prepare to be doomed.
* This method will replace all inherited stylesheets with clones from the stylesheet
* collection.
*
* @param sc the stylesheet collection that contains the updated information and
* that should be assigned with that element.
* @throws NullPointerException if the given stylesheet collection is null.
* @throws InvalidStyleSheetCollectionException if there is an other stylesheet
* collection already registered with that element.
*/
public void updateStyleSheetCollection(final StyleSheetCollection sc)
throws InvalidStyleSheetCollectionException
{
if (sc == null)
{
throw new NullPointerException("StyleSheetCollection is null.");
}
if (getStyleSheetCollection() != null)
{
throw new InvalidStyleSheetCollectionException
("There is a stylesheet collection already registered.");
}
sc.updateStyleSheet(getStyle());
registerStyleSheetCollection(sc);
}
/**
* Returns the tree lock object for the element tree.
*
* @return the treelock object.
*/
public final Object getTreeLock ()
{
if (getParent() != null)
{
return getParent().getTreeLock();
}
return treeLock;
}
/**
* Checks, whether the layout manager should compute the size of this element
* based on the current content.
*
* @return true, if the element is dynamic, false otherwise.
*/
public boolean isDynamicContent()
{
return getStyle().getBooleanStyleProperty(ElementStyleSheet.DYNAMIC_HEIGHT);
}
/**
* Defines the stylesheet property for the dynamic attribute. Calling this
* function with either parameter will override any previously defined value
* for the dynamic attribute. The value can no longer be inherited from parent
* stylesheets.
*
* @param dynamicContent the new state of the dynamic flag.
*/
public void setDynamicContent(final boolean dynamicContent)
{
getStyle().setBooleanStyleProperty
(ElementStyleSheet.DYNAMIC_HEIGHT, dynamicContent);
if (dynamicContent == true)
{
setLayoutCacheable(false);
}
}
/**
* Returns whether the layout of this element is cacheable.
*
* @return true, if the layout is cacheable, false otherwise.
*/
public boolean isLayoutCacheable()
{
return getStyle().getBooleanStyleProperty
(ElementStyleSheet.ELEMENT_LAYOUT_CACHEABLE);
}
/**
* Defines whether the layout of this element can be cached.
* <p>
* Calling this function with either parameter will override any
* previously defined value for the layoutcachable attribute.
* The value can no longer be inherited from parent stylesheets.
*
* @param layoutCacheable true, if the layout is cacheable, false otherwise.
*/
public void setLayoutCacheable(final boolean layoutCacheable)
{
getStyle().setBooleanStyleProperty
(ElementStyleSheet.ELEMENT_LAYOUT_CACHEABLE, layoutCacheable);
}
/**
* Returns the minimum size of this element, if defined.
* Warning: The returned object is not immutable and should
* not be changed.
*
* @return the minimum size
*/
public Dimension2D getMinimumSize()
{
return (Dimension2D) getStyle().getStyleProperty
(ElementStyleSheet.MINIMUMSIZE);
}
/**
* Defines the stylesheet property for the minimum element size.
*
* @param minimumSize the new minimum size or null, if the value should
* be inherited.
*/
public void setMinimumSize(final Dimension2D minimumSize)
{
getStyle().setStyleProperty (ElementStyleSheet.MINIMUMSIZE,
minimumSize);
}
/**
* Returns the maximum size of this element, if defined.
* Warning: The returned object is not immutable and should
* not be changed.
*
* @return the maximum size
*/
public Dimension2D getMaximumSize()
{
return (Dimension2D) getStyle().getStyleProperty
(ElementStyleSheet.MAXIMUMSIZE);
}
/**
* Defines the stylesheet property for the maximum element size.
*
* @param maximumSize the new maximum size or null, if the value should
* be inherited.
*/
public void setMaximumSize(final Dimension2D maximumSize)
{
getStyle().setStyleProperty (ElementStyleSheet.MAXIMUMSIZE,
maximumSize);
}
/**
* Returns the preferred size of this element, if defined.
* Warning: The returned object is not immutable and should
* not be changed.
*
* @return the preferred size
*/
public Dimension2D getPreferredSize()
{
return (Dimension2D) getStyle().getStyleProperty
(ElementStyleSheet.PREFERREDSIZE);
}
/**
* Defines the stylesheet property for the preferred element size.
*
* @param preferredSize the new preferred size or null, if the value should
* be inherited.
*/
public void setPreferredSize(final Dimension2D preferredSize)
{
getStyle().setStyleProperty (ElementStyleSheet.PREFERREDSIZE,
preferredSize);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -