FisheyeList
Another component based upon the dojotoolkit.org widget library. This allows for a fisheye view of zooming in on a list of images. The contents of the list are specified by creating html elements containing the dojo attribute dojoType="FisheyeListItem".
See also: Live Demo
Parameters
| Name | Type | Direction | Required | Default | Description |
|---|---|---|---|---|---|
| itemWidth | String | no | 40 | The default width of each item in the list. | |
| itemHeight | String | no | 40 | The default height of each item in the list. | |
| itemMaxWidth | String | no | 80 | The max zoom width of each item in the list. | |
| itemMaxHeight | String | no | 80 | The max zoom height of each item in the list. | |
| orientation | horizontal/vertical | no | horizontal | Specifies whether the list is rendered vertically or horizontally. | |
| effectUnits | String | no | 2 | The unit base used to calculate zooming behaviour. | |
| itemPadding | String | no | 10 | The amount of internal padding displayed between each item. | |
| attachEdge | String | no | right | Not completely sure, I think it means which edge of the icon the zoom appears to zoom towards. | |
| labelEdge | bottom/top/right/left | no | bottom | The edge of the icon that any labels found in the list will be rendered on. | |
| breakOn | int | no | If specified, will break the line of fisheye list items every breakOn number of items. | ||
| source | List/Collection/Object[] | yes | The items to be rendered. Will iterate over them like a For loop, allowing you to supply the body content. | ||
| value | Object | no | The value property to be bound for each value in the source. | ||
| index | int | no | The list index property to be bound for each value in the source. |
Body: allowed
Informal parameters: allowed
Reserved parameters: none
Examples
FisheyeList from demo
HTML template
<div id="explorer">
<h3>Country Explorer</h3>
<div jwcid="@Any" id="container">
<div jwcid="fisheye" >
<div jwcid="@Any"
id="ognl:currItem.getCountry()"
class="listItem"
dojoType="FisheyeListItem">
<a href="javascript:alert('shouldnt happen');" >
<img jwcid="flagImage" width="34" height="18"/></a>
</div>
</div>
</div>
<div jwcid="selectedCountries" >
<ul id="selectList">
<span jwcid="selCountries" >
<li jwcid="@Any" id="ognl:currItem"><span jwcid="@Insert" value="ognl:currItem" /></li>
</span>
</ul>
</div>
<div id="statusBar" >
Total:<span id="total" jwcid="@Any" class="summary" >
<span jwcid="@Insert" value="ognl:selectedItems.size()"/></span>
<span jwcid="removeDrop"><img id="trash" src="img/trash-empty.png" /></span>
</div>
</div>
Page specification
<page-specification class="net.sf.tacos.demo.pages.ajax.DragAndDropExample">
<description>Shows complex interactions</description>
<property name="currItem" />
<property name="index" />
<property name="selectItem" />
<property name="selectedItems" persist="session"
initial-value="ognl:new java.util.HashSet()"/>
<component id="foreachItem" type="tacos:PartialFor">
<binding name="source" value="items"/>
<binding name="value" value="currItem"/>
<binding name="index" value="ognl:index" />
</component>
<component id="selCountries" type="tacos:PartialFor">
<binding name="source" value="ognl:selectedItems"/>
<binding name="value" value="ognl:currItem"/>
</component>
<component id="addCountryLink" type="tacos:AjaxDirectLink">
<binding name="listener" value="listener:addCountry"/>
<binding name="updateComponents"
value="ognl:{'selectedCountries','total'}"/>
<binding name="highlight"
value="literal:any([255,255,184], 500, 500)"/>
<binding name="statusElement" value="literal:status" />
<binding name="processScripts" value="ognl:true" />
</component>
<component id="removeCountryLink" type="tacos:AjaxDirectLink">
<binding name="listener" value="listener:removeCountry"/>
<binding name="updateComponents"
value="ognl:{'selectedCountries','total','fisheye'}"/>
<binding name="highlight"
value="literal:any([255,255,184], 500, 500)"/>
<binding name="statusElement" value="literal:status" />
<binding name="processScripts" value="ognl:true" />
</component>
<component id="flagImage" type="Any">
<binding name="src"
value="ognl:'http://setiathome.free.fr/images/flags/' + currItem.country.toLowerCase() + '.gif'"/>
</component>
<component id="insertTime" type="Insert">
<binding name="format"
value="@net.sf.tacos.demo.pages.ajax.DragAndDropExample@DATE_FORMAT"/>
<binding name="value" value="new java.util.Date()"/>
</component>
<component id="selectedCountries" type="tacos:DropTarget" >
<binding name="dragSourceElement" value="literal:container" />
<binding name="dragSourceTag" value="literal:div" />
<binding name="onDragOver" value="literal:dragOver" />
<binding name="onDragOut" value="literal:dragOut" />
<binding name="insertDragSource" value="ognl:false" />
<binding name="dragSourceLink" value="component:addCountryLink" />
<binding name="acceptsTagType" value="{'div'}" />
</component>
<component id="removeDrop" type="tacos:DropTarget" >
<binding name="dragSource" value="ognl:selectedItems" />
<binding name="onDragOver" value="literal:removeDragOver" />
<binding name="onDragOut" value="literal:removeDragOut" />
<binding name="insertDragSource" value="ognl:false" />
<binding name="dragSourceLink" value="component:removeCountryLink" />
<binding name="acceptsTagType" value="{'li'}" />
</component>
<component id="fisheye" type="tacos:FisheyeList" >
<binding name="breakOn"
value="ognl:@net.sf.tacos.demo.pages.ajax.DragAndDropExample@MAX_LIST_SIZE" />
<binding name="source" value="ognl:items" />
<binding name="value" value="ognl:currItem" />
</component>
<asset name="trash" path="img/trash.png"/>
<asset name="trashEmpty" path="img/trash-empty.png"/>
</page-specification>
Java sources
public abstract class FotoManager extends BasePage {
/** Logger */
private static final Log log = LogFactory.getLog(FotoManager.class);
/** Format of times */
public static final DateFormat DATE_FORMAT =
DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG);
/** Maximum fisheyelist row size */
public static final int MAX_LIST_SIZE = 8;
/**
* Generates list of countries based on locale and sorts
* them by name.
* @return
*/
public List getItems() {
Set countries = new HashSet();
Locale[] locales = Locale.getAvailableLocales();
List items = new ArrayList(locales.length);
for (int i = 0; i < MAX_LIST_SIZE * 3; i++) {
Locale l = locales[i];
if (getSelectedItems().contains(l.getDisplayCountry())) continue;
log.debug("Country not skipped " + l.getDisplayCountry());
if (!"".equals(l.getDisplayCountry()) && !countries.contains(l.getCountry())) {
items.add(l);
countries.add(l.getCountry());
}
}
Collections.sort(items, new Comparator() {
public int compare(Object o1, Object o2) {
Locale l1 = (Locale) o1;
Locale l2 = (Locale) o2;
return l1.getDisplayCountry().compareTo(l2.getCountry());
}
});
return items;
}
/**
* Adds a new country
* @param cycle
*/
public void addCountry(IRequestCycle cycle) {
String countryCode = (String)cycle.getParameter("dragSourceId");
Locale selected = new Locale(Locale.ENGLISH.getLanguage(), countryCode);
Set s = getSelectedItems();
s.add(selected.getDisplayCountry());
setSelectedItems(s);
log.debug("Added " + selected.getDisplayCountry() + " display country.");
AjaxWebRequest ajax =
(AjaxWebRequest)getRequestCycle().getAttribute(AjaxWebRequest.AJAX_REQUEST);
if (ajax != null) ajax.addStatusResponse(selected.getDisplayCountry() + " added..");
}
/**
* Removes a country from the selected list
* @param cycle
*/
public void removeCountry(IRequestCycle cycle) {
String countryCode = (String)cycle.getParameter("dragSourceId");
Set s = getSelectedItems();
s.remove(countryCode);
setSelectedItems(s);
log.debug("Removed " + countryCode + " display country.");
AjaxWebRequest ajax =
(AjaxWebRequest)getRequestCycle().getAttribute(AjaxWebRequest.AJAX_REQUEST);
if (ajax != null) ajax.addStatusResponse(countryCode + " removed..");
}
public abstract Set getSelectedItems();
public abstract void setSelectedItems(Set selectedItems);
}

