View Javadoc
1 package com.tirsen.angkor.widget; 2 3 import com.tirsen.angkor.Debug; 4 import com.tirsen.angkor.RenderContext; 5 import com.tirsen.angkor.View; 6 import com.tirsen.angkor.Component; 7 import com.tirsen.angkor.event.Action; 8 import com.tirsen.angkor.event.ActionListener; 9 import com.tirsen.angkor.event.ActionSource; 10 import com.tirsen.angkor.event.ActionSourceHelper; 11 import org.apache.log4j.Category; 12 13 import java.io.IOException; 14 15 /*** 16 * @author $Author: tirsen $ 17 * @version $Revision: 1.6 $ 18 * <BR> 19 * $Id: ImageMap.java,v 1.6 2002/10/13 19:59:23 tirsen Exp $ 20 */ 21 public class ImageMap extends Container 22 { 23 private static final Category logger = Category.getInstance(Debug.LOGGER_NAME); 24 25 public void add(int index, View element) 26 { 27 if (element instanceof Area) 28 super.add(index, element); 29 else 30 throw new IllegalArgumentException("A image-map can only contain ImageMap.Areas"); 31 } 32 33 public static class Area extends Component implements ActionSource 34 { 35 private ActionSourceHelper actionSourceHelper = new ActionSourceHelper(this); 36 private int x1,y1,x2,y2; 37 38 public Area(Action action, int x1, int y1, int x2, int y2) 39 { 40 actionSourceHelper.setAction(action); 41 this.x1 = x1; 42 this.y1 = y1; 43 this.x2 = x2; 44 this.y2 = y2; 45 } 46 47 public String getAlt() 48 { 49 if (getAction() == null) 50 return null; 51 else 52 return (String) getAction().getValue(Action.NAME); 53 } 54 55 public void render(RenderContext context) throws IOException 56 { 57 logger.debug(">>> Area.render"); 58 context.emptyTag("area href=\"" + context.getRequestPath() + "?" + uniqueId(context) + "=clicked\" " + 59 ((getAlt() == null) ? "" : ("alt=\"" + getAlt() + "\" ")) + 60 "coords=\"" + x1 + "," + y1 + "," + x2 + "," + y2 + "\""); 61 context.registerParsingComponent(this); 62 logger.debug("<<< Area.render"); 63 } 64 65 public boolean isParsing() 66 { 67 return true; 68 } 69 70 public void parse(RenderContext context) 71 { 72 super.parse(context); 73 if (context.getRequestParameter(getId()) != null) 74 { 75 actionSourceHelper.signalActionEvent(context); 76 } 77 } 78 79 public void removeActionListener(ActionListener listener) 80 { 81 actionSourceHelper.removeActionListener(listener); 82 } 83 84 public void addActionListener(ActionListener listener) 85 { 86 actionSourceHelper.addActionListener(listener); 87 } 88 89 public void setAction(Action action) 90 { 91 actionSourceHelper.setAction(action); 92 } 93 94 public Action getAction() 95 { 96 return actionSourceHelper.getAction(); 97 } 98 99 public void signalActionEvent() 100 { 101 actionSourceHelper.signalActionEvent(); 102 } 103 } 104 105 public void render(RenderContext context) throws IOException 106 { 107 logger.debug(">>> ImageMap.render"); 108 context.startTag("map name=\"" + uniqueId(context) + "\""); 109 renderChildren(context); 110 context.endTag("map"); 111 logger.debug("<<< ImageMap.render"); 112 } 113 }

This page was automatically generated by Maven