001: /*
002: * Copyright (C) 2005 Jeff Tassin
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018:
019: package com.jeta.swingbuilder.gui.border;
020:
021: import java.awt.Color;
022: import java.awt.Dimension;
023:
024: import javax.swing.BorderFactory;
025: import javax.swing.border.BevelBorder;
026:
027: import com.jeta.forms.components.colors.JETAColorWell;
028: import com.jeta.forms.store.properties.BevelBorderProperty;
029: import com.jeta.forms.store.properties.BorderProperty;
030: import com.jeta.forms.store.properties.ColorProperty;
031:
032: /**
033: * View that is used to create and edit bevel borders
034: *
035: * @author Jeff Tassin
036: */
037: public class BevelBorderView extends AbstractBorderView {
038:
039: /**
040: * ctor
041: */
042: public BevelBorderView() {
043: this (null);
044: }
045:
046: /**
047: * ctor
048: */
049: public BevelBorderView(BevelBorderProperty bp) {
050: super ("com/jeta/swingbuilder/gui/border/bevelBorder.frm");
051: if (bp == null) {
052: setBorderProperty(new BevelBorderProperty());
053: } else {
054: setBorderProperty(bp);
055: }
056: setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
057: addCustomColor(BevelBorderNames.ID_HIGHLIGHT_INNER_COLOR,
058: ColorProperty.DEFAULT_COLOR);
059: addCustomColor(BevelBorderNames.ID_HIGHLIGHT_OUTER_COLOR,
060: ColorProperty.DEFAULT_COLOR);
061: addCustomColor(BevelBorderNames.ID_SHADOW_OUTER_COLOR,
062: ColorProperty.DEFAULT_COLOR);
063: addCustomColor(BevelBorderNames.ID_SHADOW_INNER_COLOR,
064: ColorProperty.DEFAULT_COLOR);
065: }
066:
067: /**
068: * Creates a border property based on the view inputs
069: */
070: public BorderProperty createBorderProperty() {
071: BevelBorderProperty bp = new BevelBorderProperty(getType());
072: bp
073: .setHighlightInnerColorProperty(getColorProperty(BevelBorderNames.ID_HIGHLIGHT_INNER_COLOR));
074: bp
075: .setHighlightOuterColorProperty(getColorProperty(BevelBorderNames.ID_HIGHLIGHT_OUTER_COLOR));
076: bp
077: .setShadowOuterColorProperty(getColorProperty(BevelBorderNames.ID_SHADOW_OUTER_COLOR));
078: bp
079: .setShadowInnerColorProperty(getColorProperty(BevelBorderNames.ID_SHADOW_INNER_COLOR));
080: setTitle(bp);
081: return bp;
082: }
083:
084: /**
085: * @return a description for this view. Typically used for a title in a
086: * dialog
087: */
088: public String getDescription() {
089: return "Bevel Border";
090: }
091:
092: /**
093: * @return the preferred size for this view
094: */
095: public Dimension getPreferredSize() {
096: return super .getPreferredSize();
097: }
098:
099: /**
100: * @return the type of border (RAISED or LOWERED)
101: */
102: public int getType() {
103: if (getView()
104: .getBoolean(BevelBorderNames.ID_BEVEL_RAISED_RADIO)) {
105: return BevelBorder.RAISED;
106: } else {
107: return BevelBorder.LOWERED;
108: }
109: }
110:
111: /**
112: * Updates this view based on the given border settings
113: */
114: public void setBorderProperty(BorderProperty border) {
115: super .setBorderProperty(border);
116: if (border instanceof BevelBorderProperty) {
117: BevelBorderProperty bb = (BevelBorderProperty) border;
118: if (bb.getBevelType() == BevelBorder.RAISED) {
119: getView().getRadioButton(
120: BevelBorderNames.ID_BEVEL_RAISED_RADIO)
121: .setSelected(true);
122: } else {
123: getView().getRadioButton(
124: BevelBorderNames.ID_BEVEL_LOWERED_RADIO)
125: .setSelected(true);
126: }
127:
128: setColorProperty(BevelBorderNames.ID_HIGHLIGHT_INNER_COLOR,
129: bb.getHighlightInnerColorProperty());
130: setColorProperty(BevelBorderNames.ID_HIGHLIGHT_OUTER_COLOR,
131: bb.getHighlightOuterColorProperty());
132: setColorProperty(BevelBorderNames.ID_SHADOW_OUTER_COLOR, bb
133: .getShadowOuterColorProperty());
134: setColorProperty(BevelBorderNames.ID_SHADOW_INNER_COLOR, bb
135: .getShadowInnerColorProperty());
136: } else {
137: assert (false);
138: }
139: }
140:
141: public void setColor(String compId, Color c) {
142: JETAColorWell inkwell = (JETAColorWell) getView()
143: .getComponentByName(compId);
144: inkwell.setColor(c);
145: }
146:
147: }
|