001: /*
002: * Copyright Javelin Software, All rights reserved.
003: */
004:
005: package com.javelin.swinglets.border;
006:
007: import java.util.*;
008: import java.awt.*;
009: import java.io.*;
010:
011: import com.javelin.swinglets.*;
012: import com.javelin.swinglets.plaf.*;
013:
014: /**
015: * SCompoundBorder is used to render a set of nested borders
016: *
017: * @author Robin Sharp
018: */
019:
020: public class SCompoundBorder extends SBorder {
021: /**
022: * Constructs a new SCompoundBorder. The borders are painted outside in.
023: */
024: public SCompoundBorder(SBorder border1, SBorder border2) {
025: this .borders = new Vector();
026:
027: this .borders.addElement(border1);
028: this .borders.addElement(border2);
029: }
030:
031: /**
032: * Constructs a new SCompoundBorder. The borders are painted outside in.
033: */
034: public SCompoundBorder(SBorder[] array) {
035: this .borders = new Vector();
036:
037: for (int index = 0; index < array.length; index++) {
038: this .borders.addElement(array[index]);
039: }
040: }
041:
042: /**
043: * Constructs a new SCompoundBorder. The borders are painted outside in.
044: */
045: public SCompoundBorder(Vector borders) {
046: this .borders = borders;
047: }
048:
049: /**
050: * Returns the name of the L&F class that renders this border.
051: */
052: public Class getUIClass() {
053: return SCompoundBorder.class;
054: }
055:
056: /**
057: * Set the borders.
058: */
059: public void setBorders(Vector borders) {
060: this .borders = borders;
061: }
062:
063: /**
064: * Get the borders.
065: */
066: public Vector getBorders() {
067: return borders;
068: }
069:
070: /**
071: * Paint this component Footer.
072: */
073: public void paintFooter(Object out, SComponent component) {
074: super .paintFooter(out, component);
075:
076: //Reset the index
077: index = 0;
078: }
079:
080: /**
081: * Get the border to be painted. Return the nested border or null.
082: */
083: public SBorder getBorder() {
084: if (borders == null || index >= borders.size()) {
085: return null;
086: }
087:
088: return (SBorder) borders.elementAt(index);
089: }
090:
091: /**
092: * Move the next nested compound border
093: */
094: public boolean nextBorder() {
095: index++;
096: return !(borders == null || index >= borders.size());
097: }
098:
099: // PRIVATE /////////////////////////////////////////////////////////////
100:
101: protected Vector borders;
102: private int index = 0;
103: }
|