001 /* 002 Copyright (C) 2002 Renaud Pawlak <renaud@aopsys.com> 003 004 This program is free software; you can redistribute it and/or modify 005 it under the terms of the GNU Lesser General Public License as 006 published by the Free Software Foundation; either version 2 of the 007 License, or (at your option) any later version. 008 009 This program is distributed in the hope that it will be useful, but 010 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 program; if not, write to the Free Software 016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 017 USA */ 018 019 package org.objectweb.jac.aspects.gui; 020 021 /** 022 * This class represents borders in GUI. */ 023 024 public class Border { 025 /** None border constant */ 026 public static final int NONE = 0; 027 /** The label of the border if any is diplayed on the left constant */ 028 public static final int LEFT = 1; 029 /** The label of the border if any is diplayed on the top constant */ 030 public static final int TOP = 2; 031 /** The label of the border if any is diplayed on the right constant */ 032 public static final int RIGHT = 3; 033 /** The label of the border if any is diplayed on the bottom constant */ 034 public static final int BOTTOM = 4; 035 /** The label of the border if any is diplayed centered constant */ 036 public static final int CENTER = 5; 037 /** The style is a line constant */ 038 public static final int LINE = 6; 039 /** The style is etched constant */ 040 public static final int ETCHED = 7; 041 /** The style is lowered constant */ 042 public static final int LOWERED = 8; 043 /** The style is raised constant */ 044 public static final int RAISED = 9; 045 046 /** 047 * Converts a string representation of the alignment to an int. */ 048 049 public static int a2iAlignment(String alignment) { 050 if (alignment.equals("LEFT")) 051 return LEFT; 052 else if (alignment.equals("RIGHT")) 053 return RIGHT; 054 else if (alignment.equals("CENTER")) 055 return CENTER; 056 else 057 throw new RuntimeException("Wrong alignment '"+alignment+"'"); 058 } 059 060 /** 061 * Converts a string representation of the style to an int. */ 062 063 public static int a2iStyle(String style) { 064 if (style.equals("LINE")) 065 return LINE; 066 else if (style.equals("ETCHED")) 067 return ETCHED; 068 else if (style.equals("LOWERED")) 069 return LOWERED; 070 else if (style.equals("RAISED")) 071 return RAISED; 072 else 073 throw new RuntimeException("Wrong style '"+style+"'"); 074 } 075 076 /** 077 * Converts an integer representation of the style to a string. */ 078 079 public static String i2aStyle(int style) { 080 if (style==LINE) 081 return "LINE"; 082 else if (style==ETCHED) 083 return "ETCHED"; 084 else if (style==LOWERED) 085 return "LOWERED"; 086 else if (style==RAISED) 087 return "RAISED"; 088 else 089 throw new RuntimeException("Wrong style '"+style+"'"); 090 } 091 092 /** 093 * Constructs a new border. 094 * 095 * @param title the border's title 096 * @param alignment the title alignment 097 * @param style the border's style */ 098 099 public Border(String title,int alignment,int style) { 100 this.title = title; 101 this.alignment = alignment; 102 this.style = style; 103 } 104 105 /** 106 * Returns true if the border has a title. */ 107 public boolean hasTitle() { 108 return title!=null; 109 } 110 111 int alignment; 112 113 /** 114 * Get the value of alignment. 115 * @return value of alignment. 116 */ 117 public int getAlignment() { 118 return alignment; 119 } 120 121 /** 122 * Set the value of alignment. 123 * @param v Value to assign to alignment. 124 */ 125 public void setAlignment(int v) { 126 this.alignment = v; 127 } 128 129 int style; 130 131 /** 132 * Get the value of style. 133 * @return value of style. 134 */ 135 public int getStyle() { 136 return style; 137 } 138 139 /** 140 * Set the value of style. 141 * @param v Value to assign to style. 142 */ 143 public void setStyle(int v) { 144 this.style = v; 145 } 146 147 String title; 148 149 /** 150 * Get the value of title. 151 * @return value of title. 152 */ 153 public String getTitle() { 154 return title; 155 } 156 157 /** 158 * Set the value of title. 159 * @param v Value to assign to title. 160 */ 161 public void setTitle(String v) { 162 this.title = v; 163 } 164 165 public String toString() { 166 return "Border{title="+title+",style="+style+"}"; 167 } 168 }