| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| org.apache.commons.jelly.tags.swing.EtchedBorderTag |
|
|
| 1 | /* |
|
| 2 | * Copyright 2002,2004 The Apache Software Foundation. |
|
| 3 | * |
|
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
| 5 | * you may not use this file except in compliance with the License. |
|
| 6 | * You may obtain a copy of the License at |
|
| 7 | * |
|
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 9 | * |
|
| 10 | * Unless required by applicable law or agreed to in writing, software |
|
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
| 13 | * See the License for the specific language governing permissions and |
|
| 14 | * limitations under the License. |
|
| 15 | */ |
|
| 16 | package org.apache.commons.jelly.tags.swing; |
|
| 17 | ||
| 18 | import java.awt.Color; |
|
| 19 | import javax.swing.BorderFactory; |
|
| 20 | import javax.swing.border.Border; |
|
| 21 | import javax.swing.border.EtchedBorder; |
|
| 22 | ||
| 23 | import org.apache.commons.jelly.JellyTagException; |
|
| 24 | import org.apache.commons.jelly.MissingAttributeException; |
|
| 25 | import org.apache.commons.jelly.XMLOutput; |
|
| 26 | import org.apache.commons.logging.Log; |
|
| 27 | import org.apache.commons.logging.LogFactory; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * Creates an etched border. |
|
| 31 | * The border will either be exported as a variable defined by the 'var' attribute |
|
| 32 | * or will be set on the parent widget's border property |
|
| 33 | * |
|
| 34 | * @author <a href="mailto:robert@bull-enterprises.com">Robert McIntosh</a> |
|
| 35 | * @version $Revision: 155420 $ |
|
| 36 | */ |
|
| 37 | 0 | public class EtchedBorderTag extends BorderTagSupport { |
| 38 | ||
| 39 | /** The Log to which logging calls will be made. */ |
|
| 40 | 8 | private static final Log log = LogFactory.getLog(EtchedBorderTag.class); |
| 41 | ||
| 42 | 0 | private int etchType = -1; |
| 43 | 0 | private Color highlight = null; |
| 44 | 0 | private Color shadow = null; |
| 45 | ||
| 46 | // Tag interface |
|
| 47 | //------------------------------------------------------------------------- |
|
| 48 | public void doTag(final XMLOutput output) throws MissingAttributeException, JellyTagException { |
|
| 49 | 0 | if( highlight != null && shadow == class="keyword">null ) { |
| 50 | 0 | throw new MissingAttributeException("shadow must be supplied when highlight is supplied"); |
| 51 | } |
|
| 52 | 0 | if( shadow != null && highlight == class="keyword">null) { |
| 53 | 0 | throw new MissingAttributeException("highlight must be supplied when shadow is supplied"); |
| 54 | } |
|
| 55 | 0 | if( etchType != EtchedBorder.LOWERED || etchType != EtchedBorder.RAISED ) { |
| 56 | 0 | if( log.isDebugEnabled() ) log.debug( "etchType set to [" + etchType + "], which is invalid. Reseting to -1" ); |
| 57 | } |
|
| 58 | 0 | super.doTag(output); |
| 59 | 0 | } |
| 60 | ||
| 61 | // Properties |
|
| 62 | //------------------------------------------------------------------------- |
|
| 63 | /** |
|
| 64 | * Sets the etch type. Must be either EtchedBorder.LOWERED or EtchedBorder.RAISED |
|
| 65 | * @param type |
|
| 66 | */ |
|
| 67 | public void setEtchType( int type ) { |
|
| 68 | 0 | etchType = type; |
| 69 | 0 | } |
| 70 | ||
| 71 | /** |
|
| 72 | * Sets the highlight color |
|
| 73 | * @param highlight |
|
| 74 | */ |
|
| 75 | public void setHighlight( Color highlight ) { |
|
| 76 | 0 | this.highlight = highlight; |
| 77 | 0 | } |
| 78 | ||
| 79 | /** |
|
| 80 | * Sets the shadow color |
|
| 81 | * @param shadow |
|
| 82 | */ |
|
| 83 | public void setTop( Color shadow ) { |
|
| 84 | 0 | this.shadow = shadow; |
| 85 | 0 | } |
| 86 | ||
| 87 | /** |
|
| 88 | * Factory method to create a new EtchedBorder instance. |
|
| 89 | */ |
|
| 90 | protected Border createBorder() { |
|
| 91 | 0 | if( etchType == -1 && shadow == null && highlight == class="keyword">null) { |
| 92 | 0 | return BorderFactory.createEtchedBorder(); |
| 93 | } |
|
| 94 | 0 | else if ( highlight != null && shadow != class="keyword">null && etchType > -1 ) { |
| 95 | 0 | return BorderFactory.createEtchedBorder( etchType, highlight, shadow ); |
| 96 | } |
|
| 97 | else { |
|
| 98 | 0 | return BorderFactory.createEtchedBorder( highlight, shadow ); |
| 99 | } |
|
| 100 | ||
| 101 | } |
|
| 102 | ||
| 103 | } |
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |