|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
Image.java | 50% | 81.8% | 100% | 75% |
|
1 |
// Copyright 2004, 2005 The Apache Software Foundation
|
|
2 |
//
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
5 |
// You may obtain a copy of the License at
|
|
6 |
//
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8 |
//
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12 |
// See the License for the specific language governing permissions and
|
|
13 |
// limitations under the License.
|
|
14 |
|
|
15 |
package org.apache.tapestry.html;
|
|
16 |
|
|
17 |
import org.apache.tapestry.AbstractComponent;
|
|
18 |
import org.apache.tapestry.IAsset;
|
|
19 |
import org.apache.tapestry.IMarkupWriter;
|
|
20 |
import org.apache.tapestry.IRequestCycle;
|
|
21 |
import org.apache.tapestry.Tapestry;
|
|
22 |
|
|
23 |
/**
|
|
24 |
* Used to insert an image. To create a rollover image, use the
|
|
25 |
* {@link Rollover} class, which integrates a link with the image assets
|
|
26 |
* used with the button.
|
|
27 |
*
|
|
28 |
* [<a href="../../../../../ComponentReference/Image.html">Component Reference</a>]
|
|
29 |
*
|
|
30 |
*
|
|
31 |
* @author Howard Lewis Ship
|
|
32 |
*
|
|
33 |
**/
|
|
34 |
|
|
35 |
public abstract class Image extends AbstractComponent |
|
36 |
{ |
|
37 |
/**
|
|
38 |
* Renders the <img> element.
|
|
39 |
*
|
|
40 |
*
|
|
41 |
**/
|
|
42 |
|
|
43 | 10 |
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) |
44 |
{ |
|
45 |
// Doesn't contain a body so no need to do anything on rewind (assumes no
|
|
46 |
// sideffects to accessor methods via bindings).
|
|
47 |
|
|
48 | 10 |
if (cycle.isRewinding())
|
49 | 0 |
return;
|
50 |
|
|
51 | 10 |
IAsset imageAsset = getImage(); |
52 |
|
|
53 | 10 |
if (imageAsset == null) |
54 | 0 |
throw Tapestry.createRequiredParameterException(this, "image"); |
55 |
|
|
56 | 10 |
String imageURL = imageAsset.buildURL(cycle); |
57 |
|
|
58 | 10 |
writer.beginEmpty("img");
|
59 |
|
|
60 | 10 |
writer.attribute("src", imageURL);
|
61 |
|
|
62 | 10 |
writer.attribute("border", getBorder());
|
63 |
|
|
64 | 10 |
renderInformalParameters(writer, cycle); |
65 |
|
|
66 | 10 |
writer.closeTag(); |
67 |
|
|
68 |
} |
|
69 |
|
|
70 |
public abstract IAsset getImage();
|
|
71 |
|
|
72 |
public abstract int getBorder(); |
|
73 |
} |
|