001 /*
002 * This file is part of the Echo Point Project. This project is a
003 * collection of Components that have extended the Echo Web Application
004 * Framework Version 3.
005 *
006 * Version: MPL 1.1
007 *
008 * The contents of this file are subject to the Mozilla Public License Version
009 * 1.1 (the "License"); you may not use this file except in compliance with
010 * the License. You may obtain a copy of the License at
011 * http://www.mozilla.org/MPL/
012 *
013 * Software distributed under the License is distributed on an "AS IS" basis,
014 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
015 * for the specific language governing rights and limitations under the
016 * License.
017 */
018
019 package echopoint;
020
021 import echopoint.able.Insetable;
022 import nextapp.echo.app.*;
023
024 /**
025 * The <code>Separator</code> class is a <code>Component</code>
026 * that provides a simple separator within menus or between
027 * other <code>Components</code>
028 * <p>
029 * It consists of a top line and bottom line, that can have width
030 * and color values. It also has an Inset value around it.
031 *
032 * @author Brad Baker <p>Modified by HansH 2009-04-03</p>
033 * @version $Id: Separator.java 208 2009-05-25 02:40:35Z sptrakesh $
034 */
035
036 public class Separator extends ComponentEx implements Insetable {
037
038 public static final String PROPERTY_BOTTOM_SIZE = "bottomSize";
039 public static final String PROPERTY_BOTTOM_COLOR = "bottomColor";
040 public static final String PROPERTY_TOP_SIZE = "topSize";
041 public static final String PROPERTY_TOP_COLOR = "topColor";
042
043 /** the default bottom color */
044 public static final Color DEFAULT_BOTTOM_COLOR = new Color(0xF0,0xF0,0xF0);
045 /** the default insets are {4,2} */
046 public static final Insets DEFAULT_INSETS = new Insets(4,2);
047 /** the default top color */
048 public static final Color DEFAULT_TOP_COLOR = new Color(0x90,0x90,0x90);
049 /** the default top size is 1 */
050 public static final Extent DEFAULT_TOP_SIZE = new Extent(1);
051 /** the default bottom size is 1 */
052 public static final Extent DEFAULT_BOTTOM_SIZE = new Extent(1);
053
054 public static final Style DEFAULT_STYLE;
055
056
057 static {
058 MutableStyle style = new MutableStyle();
059 style.set(PROPERTY_BOTTOM_COLOR,DEFAULT_BOTTOM_COLOR);
060 style.set(PROPERTY_BOTTOM_SIZE,DEFAULT_BOTTOM_SIZE);
061 style.set(PROPERTY_TOP_COLOR,DEFAULT_TOP_COLOR);
062 style.set(PROPERTY_TOP_SIZE,DEFAULT_TOP_SIZE);
063 style.set(PROPERTY_INSETS,DEFAULT_INSETS);
064 style.set(PROPERTY_OUTSETS,DEFAULT_OUTSETS);
065 DEFAULT_STYLE = style;
066 }
067
068 /**
069 * Constructs a <code>Separator</code>.
070 *
071 */
072 public Separator() {
073 super();
074 setStyle(DEFAULT_STYLE);
075 }
076 /**
077 * The color of the bottom separator line
078 * @return The color of the bottom separator line
079 */
080 public Color getBottomColor() {
081 return (Color) get(this, PROPERTY_BOTTOM_COLOR, DEFAULT_BOTTOM_COLOR);
082 }
083
084 /**
085 * The size of the bottom separator line
086 * @return The size of the bottom separator line
087 */
088 public Extent getBottomSize() {
089 return (Extent) get(this, PROPERTY_BOTTOM_SIZE, DEFAULT_BOTTOM_SIZE);
090 }
091
092 /**
093 * The color of the top separator line
094 * @return The color of the top separator line
095 */
096 public Color getTopColor() {
097 return (Color) get(this, PROPERTY_TOP_COLOR, DEFAULT_TOP_COLOR);
098 }
099
100 /**
101 * The size of the top separator line
102 * @return The color of the top separator line
103 */
104 public Extent getTopSize() {
105 return (Extent) get(this, PROPERTY_TOP_SIZE, DEFAULT_TOP_SIZE);
106 }
107
108 public void setBottomColor(Color color) {
109 set(PROPERTY_BOTTOM_COLOR,color);
110 }
111
112 public void setBottomSize(Extent newValue) {
113 set(PROPERTY_BOTTOM_SIZE,newValue);
114 }
115
116 public void setTopColor(Color newValue) {
117 set(PROPERTY_TOP_COLOR,newValue);
118 }
119
120 public void setTopSize(Extent newValue) {
121 set(PROPERTY_TOP_SIZE,newValue);
122 }
123 /**
124 * @see echopoint.able.Insetable#getInsets()
125 */
126 public Insets getInsets() {
127 return (Insets) get(this, PROPERTY_INSETS, DEFAULT_INSETS);
128 }
129 /**
130 * @see echopoint.able.Insetable#getOutsets()
131 */
132 public Insets getOutsets() {
133 return (Insets) get(this, PROPERTY_OUTSETS, DEFAULT_OUTSETS);
134 }
135 /**
136 * @see echopoint.able.Insetable#setInsets(nextapp.echo.app.Insets)
137 */
138 public void setInsets(Insets newValue) {
139 set(PROPERTY_INSETS,newValue);
140 }
141 /**
142 * @see echopoint.able.Insetable#setOutsets(nextapp.echo.app.Insets)
143 */
144 public void setOutsets(Insets newValue) {
145 set(PROPERTY_OUTSETS,newValue);
146 }
147 }