001: /*
002: * Copyright Javelin Software, All rights reserved.
003: */
004:
005: package com.javelin.swinglets;
006:
007: import java.awt.*;
008: import java.util.*;
009: import java.io.*;
010:
011: /**
012: * SArea defines an area in an SImage that can be associated with
013: * text and links.
014: * <P>
015: * The SArea class is based on HTML ImageMap semantics. It can
016: * be used to create RECTANGLE, CIRCLE or POLYGON area.
017: *
018: * @author Robin Sharp
019: */
020:
021: import java.awt.*;
022: import java.io.*;
023: import java.util.*;
024:
025: public class SArea {
026: /**
027: * This is a Rectangle. The Rectange property is valid.
028: */
029: public final static String RECTANGLE = "RECT";
030:
031: /**
032: * This is a Circle. The Point and radius properties are valid.
033: */
034: public final static String CIRCLE = "CIRCLE";
035:
036: /**
037: * This is a Polygon. The Points Enumeration property is valid.
038: */
039: public final static String POLYGON = "POLY";
040:
041: /**
042: * Construct a Rectangular area, without a link.
043: */
044: public SArea(Rectangle rectangle, String text) {
045: this .shape = RECTANGLE;
046: this .rectangle = rectangle;
047: this .text = text;
048: }
049:
050: /**
051: * Construct a Rectangular area, with a link.
052: */
053: public SArea(Rectangle rectangle, String text, SLink link) {
054: this .shape = RECTANGLE;
055: this .rectangle = rectangle;
056: this .text = text;
057: this .link = link;
058: }
059:
060: /**
061: * Construct a Circular area, without a link.
062: */
063: public SArea(Point point, int radius, String text) {
064: this .shape = CIRCLE;
065: this .point = point;
066: this .radius = radius;
067: this .text = text;
068: }
069:
070: /**
071: * Construct a Circular area, with a link.
072: */
073: public SArea(Point point, int radius, String text, SLink link) {
074: this .shape = CIRCLE;
075: this .point = point;
076: this .radius = radius;
077: this .text = text;
078: this .link = link;
079: }
080:
081: /**
082: * Construct a Polygon area, without a link.
083: */
084: public SArea(Polygon polygon, String text) {
085: this .shape = POLYGON;
086: this .polygon = polygon;
087: this .text = text;
088: }
089:
090: /**
091: * Construct a Polygon area, with a link.
092: */
093: public SArea(Polygon polygon, String text, SLink link) {
094: this .shape = POLYGON;
095: this .polygon = polygon;
096: this .text = text;
097: this .link = link;
098: }
099:
100: /**
101: * Get the Shape
102: */
103: public String getShape() {
104: return shape;
105: }
106:
107: /**
108: * Get the Text
109: */
110: public String getText() {
111: return text;
112: }
113:
114: /**
115: * Set the SLink
116: */
117: public SArea setText(String text) {
118: this .text = text;
119: return this ;
120: }
121:
122: /**
123: * Get the SLink
124: */
125: public SLink getLink() {
126: return link;
127: }
128:
129: /**
130: * Set the SLink
131: */
132: public SArea setLink(SLink link) {
133: this .link = link;
134: return this ;
135: }
136:
137: // RECTANGLE ////////////////////////////////////////////////
138:
139: /**
140: * Get the Rectangle
141: */
142: public Rectangle getRectangle() {
143: return rectangle;
144: }
145:
146: /**
147: * Set the Rectangle
148: */
149: public void setRectangle(Rectangle rectangle) {
150: this .rectangle = rectangle;
151: }
152:
153: // CIRCLE ////////////////////////////////////////////////
154:
155: /**
156: * Get the Point
157: */
158: public Point getPoint() {
159: return point;
160: }
161:
162: /**
163: * Set the Rectangle
164: */
165: public SArea setPoint(Point point) {
166: this .point = point;
167: return this ;
168: }
169:
170: /**
171: * Get the Radius
172: */
173: public int getRadius() {
174: return radius;
175: }
176:
177: /**
178: * Set the Radius
179: */
180: public SArea setRadius(int radius) {
181: this .radius = radius;
182: return this ;
183: }
184:
185: // POLYGON /////////////////////////////////////////////////
186:
187: /**
188: * Get the Polygon
189: */
190: public Polygon getPolygon() {
191: return polygon;
192: }
193:
194: /**
195: * Set the Rectangle
196: */
197: public SArea setPolygon(Polygon polygon) {
198: this .polygon = polygon;
199: return this ;
200: }
201:
202: // PRIVATE /////////////////////////////////////////////////
203:
204: protected String shape;
205: protected String text;
206: protected SLink link;
207:
208: protected Rectangle rectangle;
209:
210: protected Point point;
211: protected int radius;
212:
213: protected Polygon polygon;
214: }
|