Class AbstractWebComponentDepictor<C extends Component>

    • Field Detail

      • BODY_START_PATTERN

        protected static final java.util.regex.Pattern BODY_START_PATTERN
        The pattern matching the HTML body start tag.
      • BODY_END_PATTERN

        protected static final java.util.regex.Pattern BODY_END_PATTERN
        The pattern matching the HTML body end tag.
    • Constructor Detail

      • AbstractWebComponentDepictor

        public AbstractWebComponentDepictor()
        Default constructor with no element representation.
      • AbstractWebComponentDepictor

        public AbstractWebComponentDepictor​(java.net.URI namespaceURI,
                                            java.lang.String localName)
        Element namespace and local name constructor that doesn't create an empty element, even if there is no content.
        Parameters:
        namespaceURI - The URI of the XML namespace of the element, or null if there is no namespace.
        localName - The local name of the element with no prefix, or null if this component should not be rendered as an element.
      • AbstractWebComponentDepictor

        public AbstractWebComponentDepictor​(java.net.URI namespaceURI,
                                            java.lang.String localName,
                                            boolean isEmptyElementAllowed)
        Element namespace and local name constructor.
        Parameters:
        namespaceURI - The URI of the XML namespace of the element, or null if there is no namespace.
        localName - The local name of the element with no prefix, or null if this component should not be rendered as an element.
        isEmptyElementAllowed - Whether an empty element can be created if there is no content.
    • Method Detail

      • getNamespaceURI

        public java.net.URI getNamespaceURI​(C component)
        Determines the namespace URI of the XML element.
        Parameters:
        component - The component for which an element namespace URI should be retrieved.
        Returns:
        The URI of the XML namespace of the element, or null if there is no namespace.
      • getLocalName

        public java.lang.String getLocalName()
        Determines the local name of the XML element.
        Returns:
        The local name of the element with no prefix, or null if this component should not be rendered as an element.
      • isEmptyElementAllowed

        public boolean isEmptyElementAllowed​(C component)
        Returns whether an empty element can be created if there is no content.
        Parameters:
        component - The component being rendered.
        Returns:
        Whether an empty element can be created if there is no content.
      • getDepictName

        public java.lang.String getDepictName()
        Description copied from interface: WebComponentDepictor
        Determines the identifier to place in the name attribute of the component's XHTML element, if appropriate. This is usually the string version of the ID of the component, but some grouped components may use a common name.
        Specified by:
        getDepictName in interface WebComponentDepictor<C extends Component>
        Returns:
        An identifier appropriate for the name attribute of the component's XHTML element.
      • depict

        public void depict()
                    throws java.io.IOException
        Updates the depiction of the object. The depiction will be marked as updated.

        This implementation marks the depiction as depicted.

        This implementation updates child components, if any.

        Orchestrates the entire depiction process for the given component.

        Updating child views is delayed until depictBody().

        A component for an individual component type should usually not override this method, opting instead to override one of the more fine-grained update view methods.

        Specified by:
        depict in interface Depictor<C extends Component>
        Overrides:
        depict in class AbstractComponentDepictor<C extends Component>
        Throws:
        java.io.IOException - if there is an error updating the depiction.
        See Also:
        depictBegin(), depictBody(), depictEnd()
      • depictBegin

        protected void depictBegin()
                            throws java.io.IOException
        Begins the depiction process.

        This version renders the beginning XML element information, if there is any, leaving the beginning tag open for attributes.

        This version writes common XHTML attributes.

        Throws:
        java.io.IOException - if there is an error updating the depiction.
      • depictBody

        protected void depictBody()
                           throws java.io.IOException
        Depicts the body of the component.

        This version depicts the children of the component.

        This version increases and decreases the indention level before and after depicting the children, respectively.

        Throws:
        java.io.IOException - if there is an error updating the depiction.
        See Also:
        AbstractComponentDepictor.depictChildren()
      • depictEnd

        protected void depictEnd()
                          throws java.io.IOException
        Ends the depiction process.

        This version renders the ending XML element information, if there is any.

        Throws:
        java.io.IOException - if there is an error updating the depiction.
      • isMouseListener

        protected boolean isMouseListener()
        Returns whether the component is interested in mouse events.

        This version returns true if the component has at least one mouse listener registered.

        Returns:
        true if the component is interested in mouse events.
      • getBaseStyleIDs

        protected java.util.Set<java.lang.String> getBaseStyleIDs​(java.lang.String prefix,
                                                                  java.lang.String suffix)
        Retrieves the base style IDs for the given component.

        This version returns the default style ID and the specified component style ID, if any.

        If the component is Selectable and is selected, the GuiseCSSStyleConstants.SELECTED_CLASS is returned.

        Parameters:
        prefix - The prefix that needs to be added to each, or null if there is no prefix to add.
        suffix - The suffix that needs to be added to each, or null if there is no suffix to add.
        Returns:
        The base style IDs for the component.
      • getBodyStyleIDs

        protected java.util.Set<java.lang.String> getBodyStyleIDs​(java.lang.String prefix,
                                                                  java.lang.String suffix)
        Retrieves the style IDs for the main part of the component.

        This version returns the base style IDs, along with any drag source, drag handle, or drop target style IDs.

        Parameters:
        prefix - The prefix that needs to be added to each, or null if there is no prefix to add.
        suffix - The suffix that needs to be added to each, or null if there is no suffix to add.
        Returns:
        The style IDs for the body of the component.
      • decorateID

        protected static java.lang.String decorateID​(java.lang.String id,
                                                     java.lang.String prefix,
                                                     java.lang.String suffix)
        Modifies an ID (such as a component ID or a style ID) by adding a prefix and/or suffix as needed.
        Parameters:
        id - The ID.
        prefix - The prefix that needs to be added, or null if there is no prefix to add.
        suffix - The suffix that needs to be added, or null if there is no suffix to add.
        Returns:
        The ID, with prefix and/or suffix added as needed.
      • addFlowStyleIDs

        protected java.util.Set<java.lang.String> addFlowStyleIDs​(java.util.Set<java.lang.String> styleIDs,
                                                                  Flow flow)
        Adds flow style IDs to the given set of style IDs based upon the given flow.

        The attribute "axisX" or "axisY" will be added to indicate whether physical flow is on the X axis or the Y axis.

        This attribute "dirLTR" or "dirRTL" will be added to indicate whether flow is left-to-right or right-to-left on the X axis.

        Parameters:
        styleIDs - The set of style IDs to which the flow IDs should be added
        flow - The logical flow, which will be converted into a physical flow and added to the style IDs.
        Returns:
        The style IDs with the physical flow axis and line direction added.
      • getOuterStyles

        protected java.util.Map<java.lang.String,​java.lang.Object> getOuterStyles()
        Retrieves the styles for the outer element of the component.

        This version returns the style for color.

        Returns:
        The styles for the outer element of the component, mapped to CSS property names.
      • getColor

        protected Color getColor()
        Determines the color for rendering the component.

        This version delegates to PresentationModel.getTextColor().

        Returns:
        The color to use for this component.
      • getBackgroundColor

        protected Color getBackgroundColor()
        Determines the background color for rendering the component.

        This version delegates to PresentationModel.getBackgroundColor().

        Returns:
        The background color to use for this component.
      • getBodyStyles

        protected java.util.Map<java.lang.String,​java.lang.Object> getBodyStyles()
        Retrieves the styles for the body element of the component.

        This version returns the style for background color.

        Returns:
        The styles for the body element of the component, mapped to CSS property names.
      • writeIDAttribute

        protected void writeIDAttribute​(java.lang.String prefix,
                                        java.lang.String suffix)
                                 throws java.io.IOException
        Writes an ID attribute with the appropriate prefixes and suffixes.
        Parameters:
        prefix - The prefix that needs to be added to each, or null if there is no prefix to add.
        suffix - The suffix that needs to be added to each, or null if there is no suffix to add.
        Throws:
        java.io.IOException - if there is an error rendering the component.
        See Also:
        DepictedObject.getDepictID()
      • writeIDClassAttributes

        protected void writeIDClassAttributes​(java.lang.String prefix,
                                              java.lang.String suffix,
                                              java.lang.String... styleIDs)
                                       throws java.io.IOException
        Writes ID and class attributes with the appropriate prefixes and suffixes.
        Parameters:
        prefix - The prefix that needs to be added to each, or null if there is no prefix to add.
        suffix - The suffix that needs to be added to each, or null if there is no suffix to add.
        styleIDs - Additional style IDs to include, without the given prefix and suffix.
        Throws:
        java.io.IOException - if there is an error rendering the component.
        See Also:
        writeIDAttribute(String, String), getBaseStyleIDs(String, String)
      • writeBodyIDClassAttributes

        protected void writeBodyIDClassAttributes​(java.lang.String prefix,
                                                  java.lang.String suffix)
                                           throws java.io.IOException
        Writes ID and class attributes for the body of the component.
        Parameters:
        prefix - The prefix that needs to be added to each, or null if there is no prefix to add.
        suffix - The suffix that needs to be added to each, or null if there is no suffix to add.
        Throws:
        java.io.IOException - if there is an error rendering the component.
        See Also:
        DepictedObject.getDepictID(), getBodyStyleIDs(String, String)
      • writeErrorMessage

        protected void writeErrorMessage()
                                  throws java.io.IOException
        Writes a message indicating any errors related to the component. The error message will be resolved so that any contained resource references will be properly written.
        Throws:
        java.io.IOException - if there is an error rendering the component.
      • writeFloatClear

        protected void writeFloatClear()
                                throws java.io.IOException
        Writes an XHTML element to clear all floats.
        Throws:
        java.io.IOException - if there is an error rendering the component.
      • writeClassAttribute

        protected void writeClassAttribute​(java.util.Set<java.lang.String> styleIDs)
                                    throws java.io.IOException
        Writes an XHTML class attribute with the given style IDs.
        Parameters:
        styleIDs - The style IDs to write.
        Throws:
        java.io.IOException - if there is an error writing the attribute.
      • writeStyleAttribute

        protected void writeStyleAttribute​(java.util.Map<java.lang.String,​java.lang.Object> styles)
                                    throws java.io.IOException
        Writes an XHTML style attribute with the given styles. If no styles are provided, the style attribute is not written.
        Parameters:
        styles - The map of styles to write, each keyed to a CSS style property.
        Throws:
        java.io.IOException - if there is an error writing the attribute.
      • writeDirectionAttribute

        protected void writeDirectionAttribute()
                                        throws java.io.IOException
        Writes an XHTML direction attribute for the X axis direction only if the given component has an orientation explicitly set.
        Throws:
        java.io.IOException - if there is an error writing the attribute.
        See Also:
        Component.getOrientation(), writeDirectionAttribute(Orientation, Flow)
      • writeDirectionAttribute

        protected void writeDirectionAttribute​(Orientation orientation,
                                               Flow flow)
                                        throws java.io.IOException
        Writes an XHTML direction attribute with the direction of the given orientation for the given flow.
        Parameters:
        orientation - The orientation information for the component.
        flow - The flow axis which direction is to represent.
        Throws:
        java.io.IOException - if there is an error writing the attribute.
      • hasLabelContent

        protected boolean hasLabelContent()
                                   throws java.io.IOException
        Determines if the given component has label content.

        This implementation delegates to hasLabelContent(LabelModel).

        Returns:
        true if the component contains some label content, such as an icon or label text.
        Throws:
        java.io.IOException - if there is an error reading the label.
      • hasLabelContent

        protected boolean hasLabelContent​(boolean includeIcon,
                                          boolean includeLabel)
                                   throws java.io.IOException
        Determines if the given component has label content.

        This implementation delegates to hasLabelContent(LabelModel, boolean, boolean).

        Parameters:
        includeIcon - true if the icon should be considered for label content.
        includeLabel - true if the label text should be considered for label content.
        Returns:
        true if the component contains some label content, such as an icon or label text.
        Throws:
        java.io.IOException - if there is an error reading the label.
      • hasLabelContent

        protected boolean hasLabelContent​(LabelModel labelModel)
                                   throws java.io.IOException
        Determines if the given label model has label content.

        This implementation delegates to hasLabelContent(LabelModel, boolean, boolean).

        Parameters:
        labelModel - The label model containing the label information.
        Returns:
        true if the label model contains some label content, such as an icon or label text.
        Throws:
        java.io.IOException - if there is an error reading the label.
      • hasLabelContent

        protected boolean hasLabelContent​(LabelModel labelModel,
                                          boolean includeIcon,
                                          boolean includeLabel)
                                   throws java.io.IOException
        Determines if the given label model has label content.
        Parameters:
        labelModel - The label model containing the label information.
        includeIcon - true if the icon should be considered for label content.
        includeLabel - true if the label text should be considered for label content.
        Returns:
        true if the label model contains some label content, such as an icon or label text.
        Throws:
        java.io.IOException - if there is an error reading the label.
      • writeLabel

        protected void writeLabel​(java.lang.String forID,
                                  java.lang.String... styleIDs)
                           throws java.io.IOException
        Writes a label element for a component, taking into account the label's content type. If no label content is present, no action occurs.

        This method calls writeLabelContent().

        Parameters:
        forID - The ID of the element with which this label is associated, or null if the label should not be associated with any particular element.
        styleIDs - Additional style IDs to include, without the given prefix and suffix.
        Throws:
        java.io.IOException - if there is an error writing the label.
        See Also:
        hasLabelContent(), writeLabelContent()
      • writeLabelContent

        protected void writeLabelContent()
                                  throws java.io.IOException
        Writes the label content of the component, taking into account the label's content type. Label styles will be written if needed. If no label content is present, no action occurs.

        This implementation delegates to writeLabelContent(LabelModel).

        Throws:
        java.io.IOException - if there is an error writing the label content.
      • writeLabelContent

        protected void writeLabelContent​(boolean includeIcon,
                                         boolean includeLabel)
                                  throws java.io.IOException
        Writes the label content of the component, taking into account the label's content type. Label styles will be written if needed. If no label content is present, no action occurs.

        This implementation delegates to writeLabelContent(LabelModel, boolean, boolean).

        Parameters:
        includeIcon - true if the icon should be considered for label content.
        includeLabel - true if the label text should be considered for label content.
        Throws:
        java.io.IOException - if there is an error writing the label content.
      • writeLabelContent

        protected void writeLabelContent​(LabelModel labelModel)
                                  throws java.io.IOException
        Writes the label content of the given label model, taking into account the label's content type. Label styles will be written if needed. If no label content is present, no action occurs.

        This method delegates to writeLabelContent(LabelModel, PresentationModel).

        Parameters:
        labelModel - The label model containing the label information.
        Throws:
        java.io.IOException - if there is an error writing the label.
      • writeLabelContent

        protected void writeLabelContent​(LabelModel labelModel,
                                         PresentationModel uiModel)
                                  throws java.io.IOException
        Writes the label content of the given label model, taking into account the label's content type. Label styles will be written if needed. If no label content is present, no action occurs.

        This method delegates to writeLabelContent(LabelModel, PresentationModel, boolean, boolean).

        Parameters:
        labelModel - The label model containing the label content.
        uiModel - The user interface model containing the label styles.
        Throws:
        java.io.IOException - if there is an error writing the label.
      • writeLabelContent

        protected void writeLabelContent​(LabelModel labelModel,
                                         boolean includeIcon,
                                         boolean includeLabel)
                                  throws java.io.IOException
        Writes the label content of the given label model, taking into account the label's content type. Label styles will be written if needed. If no label content is present, no action occurs.

        This method delegates to writeText(String, ContentType).

        Parameters:
        labelModel - The label model containing the label content.
        includeIcon - true if the icon should be considered for label content.
        includeLabel - true if the label text should be considered for label content.
        Throws:
        java.io.IOException - if there is an error writing the label.
      • writeLabelContent

        protected void writeLabelContent​(LabelModel labelModel,
                                         PresentationModel uiModel,
                                         boolean includeIcon,
                                         boolean includeLabel)
                                  throws java.io.IOException
        Writes the label content of the given label model, taking into account the label's content type. Label styles will be written if needed. If no label content is present, no action occurs.

        This method delegates to writeText(String, ContentType).

        Parameters:
        labelModel - The label model containing the label information.
        uiModel - The UI model containing the label style information.
        includeIcon - true if the icon should be considered for label content.
        includeLabel - true if the label text should be considered for label content.
        Throws:
        java.io.IOException - if there is an error writing the label.
        See Also:
        hasLabelContent(LabelModel, boolean, boolean), getLabelStyles(LabelModel, PresentationModel), writeText(String, ContentType)
      • getLabelStyles

        protected final java.util.Map<java.lang.String,​java.lang.Object> getLabelStyles()
        Retrieves the styles for the label of the component.

        This version delegates to getLabelStyles(LabelModel) using the component as the label model.

        Returns:
        The styles for the label of the component, mapped to CSS property names.
      • getLabelStyles

        protected final java.util.Map<java.lang.String,​java.lang.Object> getLabelStyles​(LabelModel labelModel)
        Retrieves the styles for the label of the component.

        This version delegates to getLabelStyles(LabelModel, PresentationModel) using the component as the UI model.

        Parameters:
        labelModel - The label model containing the label content.
        Returns:
        The styles for the label of the component, mapped to CSS property names.
      • getLabelStyles

        protected java.util.Map<java.lang.String,​java.lang.Object> getLabelStyles​(LabelModel labelModel,
                                                                                        PresentationModel uiModel)
        Retrieves the styles for the label of the component.
        Parameters:
        labelModel - The label model containing the label content.
        uiModel - The model containing the label style information.
        Returns:
        The styles for the label of the component, mapped to CSS property names.
      • writeText

        protected void writeText​(java.lang.String text,
                                 com.globalmentor.net.ContentType contentType)
                          throws java.io.IOException
        Writes text, taking the content type into consideration. XHTML text, for example, will first have its outer elements (including <body>) stripped away.
        Parameters:
        text - The text to write.
        contentType - The content type of the text.
        Throws:
        java.io.IOException - if there is an error writing the text.
        java.lang.NullPointerException - if the provided text and/or content type is null.
      • writeParameterInputs

        protected void writeParameterInputs​(com.globalmentor.model.NameValuePair<java.lang.String,​java.lang.String>... parameters)
                                     throws java.io.IOException
        Writes parameters as hidden, disabled inputs.
        Parameters:
        parameters - The parameters to write.
        Throws:
        java.io.IOException - if there is an error rendering the component.