<?xml version='1.0' encoding='UTF-8'?>
<section>
  <sectioninfo>
    <keywordset>
      <keyword>paint</keyword>
      <keyword>rich:paint2D</keyword>
      <keyword>HtmlPaint2D</keyword>
    </keywordset>
  </sectioninfo>

  <table>
    <title>Component identification parameters </title>
    <tgroup cols="2">
      <thead>
        <row>
          <entry>Name</entry>
          <entry>Value</entry>
        </row>
      </thead>
      <tbody>
        <row>
          <entry>component-type</entry>
          <entry>org.richfaces.Paint2D</entry>
        </row>
        <row>
          <entry>component-class</entry>
          <entry>org.richfaces.component.html.HtmlPaint2D</entry>
        </row>
        <row>
          <entry>component-family</entry>
          <entry>javax.faces.Output</entry>
        </row>
        <row>
          <entry>renderer-type</entry>
          <entry>org.richfaces.Paint2DRenderer</entry>
        </row>
        <row>
          <entry>tag-class</entry>
          <entry>org.richfaces.taglib.Paint2DTag</entry>
        </row>
      </tbody>
    </tgroup>
  </table>

  <section>
    <title>Creating the Component with a Page Tag</title>
    <para>To create the simplest variant on a page use the following syntax:</para>

    <para>
      <emphasis role="bold">Example:</emphasis>
    </para>
    <programlisting role="XML"><![CDATA[...
    <rich:paint2D paint="#{paint2D.paint}" data="#{paint2DModel}"/>
...
]]></programlisting>
    <para>Here <emphasis>
        <property>&quot;paint&quot;</property>
      </emphasis> specifies the method performing drawing and <emphasis>
        <property>&quot;data&quot;</property>
      </emphasis> specifies Managed Bean property keeping the data used by the method.</para>
  </section>
  <section>
    <title>Creating the Component Dynamically Using Java</title>

    <para>
      <emphasis role="bold">Example:</emphasis>
    </para>
    <programlisting role="JAVA"><![CDATA[import org.richfaces.component.html.HtmlPaint2D;
...
HtmlPaint2D myImage = new HtmlPaint2D();
...
]]></programlisting>
  </section>
  <section>
    <title>Details of Usage</title>
    <para>The example shows two main attributes of the component:</para>
    <itemizedlist>
      <listitem>
        <para>
          <emphasis>
            <property>&quot;paint&quot;</property>
          </emphasis>
        </para>
        <para>Specify a method receiving an object specified in data as a parameter and sending
          graphical information into the stream</para>
      </listitem>
      <listitem>
        <para>
          <emphasis>
            <property>&quot;data&quot;</property>
          </emphasis>
        </para>
        <para>Specifies a bean class keeping your data for rendering</para>
      </listitem>
    </itemizedlist>
    <para>
      <note>
        <title>Note:</title><para>data object should implement serializable interface </para></note>
    </para>
    <para>The <emphasis>
        <property>&quot;format&quot;</property>
      </emphasis> attribute of the component defines a format of visual data passing to the server.</para>
    <para>Generated data can be used as a cacheable or non-cacheable resource. It&apos;s defined
      with <emphasis>
        <property>&quot;cacheable&quot;</property>
      </emphasis> attribute. If cache support is turned on, a key is created in URI with a mix of
      size (width/height), <emphasis>
        <property>&quot;paint&quot;</property>
      </emphasis> method, <emphasis>
        <property>&quot;format&quot;</property>
      </emphasis> and <emphasis>
        <property>&quot;data&quot;</property>
      </emphasis> attributes.</para>

    <para>
      <emphasis role="bold">Example:</emphasis>
    </para>
    <programlisting role="JAVA"><![CDATA[paintBean.java:
      
      public void paint(Graphics2D g2, Object obj) {
          // code that gets data from the data Bean (PaintData)
          PaintData data = (PaintData) obj;
          ...
          // a code drawing a rectangle
          g2.drawRect(0, 0, data.Width, data.Height);
          ...
          // some more code placing graphical data into g2 stream below
     }
     
dataBean.java:
    
    public class PaintData implements Serializable{
        private static final long serialVersionUID = 1L;
        Integer Width=100;
        Integer Height=50;
        ...
    }
    
    page.xhtml:
    ...
    <rich:paint2D paint="#{paint2D.paint}" data="#{paint2DModel.data}"/>
    ... 
]]></programlisting>

  </section>

  <section>
    <title>Look-and-Feel Customization</title>
    <para><property>Paint2D</property> has no skin parameters and special <emphasis><property>style
          classes</property>, </emphasis> as it consists of one element generated with a
      your method on the server.</para>
    <para>To define some style properties such as an indent or a border, it&apos;s possible to
      use <emphasis>
        <property>&quot;style&quot;</property>
      </emphasis> and <emphasis>
        <property>&quot;styleClass&quot;</property>
      </emphasis> attributes on the component.</para>
  </section>
  <section>
    <title>Relevant Resources Links</title>
    <para>
      <ulink url="http://livedemo.exadel.com/richfaces-demo/richfaces/paint2D.jsf?c=paint2d"
      >Here</ulink> you can see the example of <emphasis role="bold"
      ><property>&lt;rich:paint2D&gt;</property></emphasis> usage and sources for the given example. </para>
  </section>

</section>
