1 19 20 24 25 package org.netbeans.modules.css.visual.model; 26 27 import java.util.ArrayList ; 28 import java.util.Collections ; 29 import java.util.HashMap ; 30 import java.util.List ; 31 import java.util.Map ; 32 import java.util.Set ; 33 import java.util.TreeSet ; 34 35 38 43 public final class CssProperties { 44 45 public final static String FONT_FAMILY = "font-family"; public final static String FONT_SIZE = "font-size"; public final static String FONT_STYLE = "font-style"; public final static String FONT_WEIGHT = "font-weight"; public final static String FONT_VARIANT = "font-variant"; 51 public final static String TEXT_DECORATION = "text-decoration"; public final static String TEXT_ALIGN = "text-align"; public final static String TEXT_INDENT = "text-indent"; 55 public final static String COLOR = "color"; 57 public final static String BACKGROUND = "background"; public final static String BACKGROUND_COLOR = "background-color"; public final static String BACKGROUND_IMAGE = "background-image"; public final static String BACKGROUND_REPEAT = "background-repeat"; public final static String BACKGROUND_ATTACHMENT = "background-attachment"; public final static String BACKGROUND_POSITION = "background-position"; 64 public final static String DIRECTION = "direction"; public final static String LINE_HEIGHT = "line-height"; public final static String VERTICAL_ALIGN = "vertical-align"; 68 public final static String WORD_SPACING = "word-spacing"; public final static String LETTER_SPACING = "letter-spacing"; 71 public final static String BORDER = "border"; public final static String BORDER_TOP = "border-top"; public final static String BORDER_BOTTOM = "border-bottom"; public final static String BORDER_LEFT = "border-left"; public final static String BORDER_RIGHT = "border-right"; 77 public final static String BORDER_COLOR = "border-color"; public final static String BORDER_STYLE = "border-style"; public final static String BORDER_WIDTH = "border-width"; 81 public final static String BORDER_TOP_COLOR = "border-top-color"; public final static String BORDER_TOP_STYLE = "border-top-style"; public final static String BORDER_TOP_WIDTH = "border-top-width"; 85 public final static String BORDER_BOTTOM_COLOR = "border-bottom-color"; public final static String BORDER_BOTTOM_STYLE = "border-bottom-style"; public final static String BORDER_BOTTOM_WIDTH = "border-bottom-width"; 89 public final static String BORDER_LEFT_COLOR = "border-left-color"; public final static String BORDER_LEFT_STYLE = "border-left-style"; public final static String BORDER_LEFT_WIDTH = "border-left-width"; 93 public final static String BORDER_RIGHT_COLOR = "border-right-color"; public final static String BORDER_RIGHT_STYLE = "border-right-style"; public final static String BORDER_RIGHT_WIDTH = "border-right-width"; 97 public final static String MARGIN = "margin"; public final static String MARGIN_TOP = "margin-top"; public final static String MARGIN_BOTTOM = "margin-bottom"; public final static String MARGIN_LEFT = "margin-left"; public final static String MARGIN_RIGHT = "margin-right"; 103 public final static String PADDING = "padding"; public final static String PADDING_TOP = "padding-top"; public final static String PADDING_BOTTOM = "padding-bottom"; public final static String PADDING_LEFT = "padding-left"; public final static String PADDING_RIGHT = "padding-right"; 109 public final static String POSITION = "position"; public final static String TOP = "top"; public final static String BOTTOM = "bottom"; public final static String LEFT = "left"; public final static String RIGHT = "right"; 115 public final static String WIDTH = "width"; public final static String HEIGHT = "height"; public final static String MIN_WIDTH = "min-width"; public final static String MAX_WIDTH = "max-width"; public final static String MIN_HEIGHT = "min-height"; public final static String MAX_HEIGHT = "max-height"; 122 public final static String Z_INDEX = "z-index"; public final static String VISIBILITY = "visibility"; 125 public final static String CLIP = "clip"; 127 public final static String STYLE = "style"; 129 private static Set cssPropertyNames = new TreeSet (); 130 private static void setCssPropertyNames(){ 131 cssPropertyNames.add(BACKGROUND); 132 cssPropertyNames.add(BACKGROUND_ATTACHMENT); 133 cssPropertyNames.add(BACKGROUND_COLOR); 134 cssPropertyNames.add(BACKGROUND_IMAGE); 135 cssPropertyNames.add(BACKGROUND_POSITION); 136 cssPropertyNames.add(BACKGROUND_REPEAT); 137 138 cssPropertyNames.add(BORDER); 139 cssPropertyNames.add(BORDER_COLOR); 140 cssPropertyNames.add(BORDER_STYLE); 141 cssPropertyNames.add(BORDER_WIDTH); 142 143 cssPropertyNames.add(BORDER_TOP); 144 cssPropertyNames.add(BORDER_TOP_COLOR); 145 cssPropertyNames.add(BORDER_TOP_STYLE); 146 cssPropertyNames.add(BORDER_TOP_WIDTH); 147 148 cssPropertyNames.add(BORDER_BOTTOM); 149 cssPropertyNames.add(BORDER_BOTTOM_COLOR); 150 cssPropertyNames.add(BORDER_BOTTOM_STYLE); 151 cssPropertyNames.add(BORDER_BOTTOM_WIDTH); 152 153 cssPropertyNames.add(BORDER_LEFT); 154 cssPropertyNames.add(BORDER_LEFT_COLOR); 155 cssPropertyNames.add(BORDER_LEFT_STYLE); 156 cssPropertyNames.add(BORDER_LEFT_WIDTH); 157 158 cssPropertyNames.add(BORDER_TOP); 159 cssPropertyNames.add(BORDER_TOP_COLOR); 160 cssPropertyNames.add(BORDER_TOP_STYLE); 161 cssPropertyNames.add(BORDER_TOP_WIDTH); 162 163 cssPropertyNames.add(MARGIN); 164 cssPropertyNames.add(MARGIN_TOP); 165 cssPropertyNames.add(MARGIN_BOTTOM); 166 cssPropertyNames.add(MARGIN_LEFT); 167 cssPropertyNames.add(MARGIN_RIGHT); 168 169 cssPropertyNames.add(PADDING); 170 cssPropertyNames.add(PADDING_TOP); 171 cssPropertyNames.add(PADDING_BOTTOM); 172 cssPropertyNames.add(PADDING_LEFT); 173 cssPropertyNames.add(PADDING_RIGHT); 174 175 cssPropertyNames.add(POSITION); 176 cssPropertyNames.add(TOP); 177 cssPropertyNames.add(BOTTOM); 178 cssPropertyNames.add(LEFT); 179 cssPropertyNames.add(RIGHT); 180 181 cssPropertyNames.add(WIDTH); 182 cssPropertyNames.add(HEIGHT); 183 cssPropertyNames.add(MAX_WIDTH); 184 cssPropertyNames.add(MIN_WIDTH); 185 cssPropertyNames.add(MAX_HEIGHT); 186 cssPropertyNames.add(MIN_HEIGHT); 187 188 cssPropertyNames.add(STYLE); 189 cssPropertyNames.add(CLIP); 190 cssPropertyNames.add(Z_INDEX); 191 cssPropertyNames.add(COLOR); 192 cssPropertyNames.add(DIRECTION); 193 cssPropertyNames.add(LINE_HEIGHT); 194 cssPropertyNames.add(VERTICAL_ALIGN); 195 196 cssPropertyNames.add(FONT_FAMILY); 197 cssPropertyNames.add(FONT_SIZE); 198 cssPropertyNames.add(FONT_STYLE); 199 cssPropertyNames.add(FONT_WEIGHT); 200 cssPropertyNames.add(FONT_VARIANT); 201 202 cssPropertyNames.add(TEXT_DECORATION); 203 cssPropertyNames.add(TEXT_ALIGN); 204 cssPropertyNames.add(TEXT_INDENT); 205 206 cssPropertyNames.add(COLOR); 207 } 208 209 static List cssLengthUnits = new ArrayList (); 210 private static void setCssLengthUnitNames(){ 211 cssLengthUnits.add("px"); cssLengthUnits.add("%"); cssLengthUnits.add("in"); cssLengthUnits.add("cm"); cssLengthUnits.add("mm"); cssLengthUnits.add("em"); cssLengthUnits.add("ex"); cssLengthUnits.add("picas"); } 220 221 private static List backgroundRepeatValues = new ArrayList (); 222 private static void setBackgroundRepeatValues(){ 223 backgroundRepeatValues.add("repeat"); backgroundRepeatValues.add("repeat-x"); backgroundRepeatValues.add("repeat-y"); backgroundRepeatValues.add("inherit"); } 228 229 private static List backgroundPositionValues = new ArrayList (); 230 private static void setBackgroundPositionValues(){ 231 backgroundPositionValues.add("center"); backgroundPositionValues.add("left"); backgroundPositionValues.add("right"); backgroundPositionValues.add("top"); backgroundPositionValues.add("bottom"); backgroundPositionValues.add("inherit"); } 238 239 private static List backgroundAttachmentValues = new ArrayList (); 240 private static void setBackgroundAttachmentValues(){ 241 backgroundAttachmentValues.add("none"); backgroundAttachmentValues.add("scroll"); backgroundAttachmentValues.add("fixed"); backgroundAttachmentValues.add("inherit"); } 246 247 private static List fontStyleValues = new ArrayList (); 248 private static void setFontStyleValues(){ 249 fontStyleValues.add("normal"); fontStyleValues.add("italic"); fontStyleValues.add("oblique"); fontStyleValues.add("inherit"); } 254 255 private static List fontVariantValues = new ArrayList (); 256 private static void setFontVariantValues(){ 257 fontVariantValues.add("normal"); fontVariantValues.add("small-caps"); fontVariantValues.add("inherit"); } 261 262 private static List fontWeightValues = new ArrayList (); 263 private static void setFontWeightValues(){ 264 fontWeightValues.add("normal"); fontWeightValues.add("bold"); fontWeightValues.add("bolder"); fontWeightValues.add("lighter"); fontWeightValues.add("100"); fontWeightValues.add("200"); fontWeightValues.add("300"); fontWeightValues.add("400"); fontWeightValues.add("500"); fontWeightValues.add("600"); fontWeightValues.add("700"); fontWeightValues.add("800"); fontWeightValues.add("900"); fontWeightValues.add("inherit"); } 279 280 private static List directionValues = new ArrayList (); 281 private static void setDirectionValues(){ 282 directionValues.add("ltr"); directionValues.add("rtl"); directionValues.add("inherit"); } 286 287 private static List textAlignValues = new ArrayList (); 288 private static void setTextAlignValues(){ 289 textAlignValues.add("left"); textAlignValues.add("right"); textAlignValues.add("justify"); textAlignValues.add("inherit"); } 294 295 private static List textDecorationValues = new ArrayList (); 296 private static void setTextDecorationValues(){ 297 textDecorationValues.add("none"); textDecorationValues.add("underline"); textDecorationValues.add("overline"); textDecorationValues.add("line-through"); textDecorationValues.add("inherit"); } 303 304 private static List verticalAlignValues = new ArrayList (); 305 private static void setVerticalAlignValues(){ 306 verticalAlignValues.add("baseline"); verticalAlignValues.add("sub"); verticalAlignValues.add("super"); verticalAlignValues.add("top"); verticalAlignValues.add("text-top"); verticalAlignValues.add("middle"); verticalAlignValues.add("bottom"); verticalAlignValues.add("text-bottom"); verticalAlignValues.add("inherit"); } 316 317 private static List positionValues = new ArrayList (); 318 private static void setPositionValues(){ 319 positionValues.add("static"); positionValues.add("relative"); positionValues.add("fixed"); positionValues.add("inherit"); } 324 325 private static List visiblityValues = new ArrayList (); 326 private static void setVisiblityValues(){ 327 visiblityValues.add("visible"); visiblityValues.add("hidden"); visiblityValues.add("collapse"); visiblityValues.add("inherit"); } 332 333 private static List borderStyleValues = new ArrayList (); 334 private static void setBorderStyleValues(){ 335 borderStyleValues.add("none"); borderStyleValues.add("hidden"); borderStyleValues.add("dotted"); borderStyleValues.add("dashed"); borderStyleValues.add("solid"); borderStyleValues.add("double"); borderStyleValues.add("groove"); borderStyleValues.add("ridge"); borderStyleValues.add("inset"); borderStyleValues.add("outset"); borderStyleValues.add("inherit"); } 347 348 private static List colorValues = new ArrayList (); 349 private static void setColorValues(){ 350 colorValues.add("aqua"); colorValues.add("black"); colorValues.add("blue"); colorValues.add("fuchsia"); colorValues.add("gray"); colorValues.add("green"); colorValues.add("lime"); colorValues.add("maroon"); colorValues.add("navy"); colorValues.add("olive"); colorValues.add("orange"); colorValues.add("purple"); colorValues.add("red"); colorValues.add("silver"); colorValues.add("teal"); colorValues.add("white"); colorValues.add("yellow"); } 368 369 private static Map colorNameHexMap = new HashMap (); 370 private static void setColorNameHexMap(){ 371 colorNameHexMap.put("black","#000000"); colorNameHexMap.put("gray","#808080"); colorNameHexMap.put("white","#FFFFFF"); colorNameHexMap.put("maroon","#800000"); colorNameHexMap.put("red","#FF0000"); colorNameHexMap.put("purple","#800080"); colorNameHexMap.put("fuchsia","#FF00FF"); colorNameHexMap.put("green","#008000"); colorNameHexMap.put("lime","#00FF00"); colorNameHexMap.put("olive","#808000"); colorNameHexMap.put("orange","#FFA500"); colorNameHexMap.put("yellow","#FFFF00"); colorNameHexMap.put("navy","#000080"); colorNameHexMap.put("blue","#0000FF"); colorNameHexMap.put("silver","#C0C0C0"); colorNameHexMap.put("teal","#008080"); colorNameHexMap.put("aqua","#00FFFF"); } 389 390 private static List fontFamilyValues = new ArrayList (); 391 private static void setFontFamilyValues(){ 392 fontFamilyValues.add("serif"); fontFamilyValues.add("sans-serif"); fontFamilyValues.add("monospace"); fontFamilyValues.add("fantasy"); } 397 398 private static List webFontValues = new ArrayList (); 399 private static void setWebFontValues(){ 400 webFontValues.add("Arial Black"); webFontValues.add("Cosmic Sans"); webFontValues.add("Impact"); webFontValues.add("Veranda"); webFontValues.add("Webdings"); webFontValues.add("Trebuchet"); webFontValues.add("Georgia"); webFontValues.add("Minion Web"); } 409 410 private static List fontFamiliySetValues = new ArrayList (); 411 private static void setFontFamiliySetValues(){ 412 fontFamiliySetValues.add("Arial,Helvetica,sans-serif"); fontFamiliySetValues.add("\'Times New Roman\',Times,serif"); fontFamiliySetValues.add("\'Courier New\',Courier,monospace"); fontFamiliySetValues.add("Georgia,\'Times New Roman\',times,serif"); fontFamiliySetValues.add("Verdana,Arial,Helvetica,sans-serif"); fontFamiliySetValues.add("Geneva,Arial,Helvetica,sans-serif"); fontFamiliySetValues.add("serif"); fontFamiliySetValues.add("sans-serif"); fontFamiliySetValues.add("monospace"); fontFamiliySetValues.add("cursive"); fontFamiliySetValues.add("fantasy"); } 426 427 private static List fontSizeValues = new ArrayList (); 428 private static void setFontSizeValues(){ 429 fontSizeValues.add("8"); fontSizeValues.add("10"); fontSizeValues.add("12"); fontSizeValues.add("14"); fontSizeValues.add("18"); fontSizeValues.add("24"); fontSizeValues.add("36"); fontSizeValues.add("XX-small"); fontSizeValues.add("X-small"); fontSizeValues.add("small"); fontSizeValues.add("medium"); fontSizeValues.add("large"); fontSizeValues.add("X-large"); fontSizeValues.add("XX-large"); fontSizeValues.add("smaller"); fontSizeValues.add("larger"); } 446 447 static{ 448 setCssPropertyNames(); 449 setCssLengthUnitNames(); 450 setBackgroundRepeatValues(); 451 setBackgroundPositionValues(); 452 setBackgroundAttachmentValues(); 453 setFontStyleValues(); 454 setFontVariantValues(); 455 setFontWeightValues(); 456 setDirectionValues(); 457 setTextAlignValues(); 458 setTextDecorationValues(); 459 setVerticalAlignValues(); 460 setPositionValues(); 461 setVisiblityValues(); 462 setBorderStyleValues(); 463 setColorValues(); 464 setColorNameHexMap(); 465 setWebFontValues(); 466 setFontFamilyValues(); 467 setFontFamiliySetValues(); 468 setFontSizeValues(); 469 } 470 471 475 public static String [] getCssPropertyNames(){ 476 return (String []) cssPropertyNames.toArray(new String [cssPropertyNames.size()]); 477 } 478 479 public static String [] getCssPropertyValues(String cssProperty) { 480 if(BACKGROUND_REPEAT.equals(cssProperty)){ 481 return (String []) backgroundRepeatValues.toArray(new String [backgroundRepeatValues.size()]); 482 }else if(BACKGROUND_POSITION.equals(cssProperty)){ 483 return (String []) backgroundPositionValues.toArray(new String [backgroundPositionValues.size()]); 484 }else if(BACKGROUND_ATTACHMENT.equals(cssProperty)){ 485 return (String []) backgroundAttachmentValues.toArray(new String [backgroundAttachmentValues.size()]); 486 }else if(FONT_STYLE.equals(cssProperty)){ 487 return (String []) fontStyleValues.toArray(new String [fontStyleValues.size()]); 488 }else if(FONT_VARIANT.equals(cssProperty)){ 489 return (String []) fontVariantValues.toArray(new String [fontVariantValues.size()]); 490 }else if(FONT_WEIGHT.equals(cssProperty)){ 491 return (String []) fontWeightValues.toArray(new String [fontWeightValues.size()]); 492 }else if(DIRECTION.equals(cssProperty)){ 493 return (String []) directionValues.toArray(new String [directionValues.size()]); 494 }else if(TEXT_ALIGN.equals(cssProperty)){ 495 return (String []) textAlignValues.toArray(new String [textAlignValues.size()]); 496 }else if(TEXT_DECORATION.equals(cssProperty)){ 497 return (String []) textDecorationValues.toArray(new String [textDecorationValues.size()]); 498 }else if(VERTICAL_ALIGN.equals(cssProperty)){ 499 return (String []) verticalAlignValues.toArray(new String [verticalAlignValues.size()]); 500 }else if(POSITION.equals(cssProperty)){ 501 return (String []) positionValues.toArray(new String [positionValues.size()]); 502 }else if(VISIBILITY.equals(cssProperty)){ 503 return (String []) visiblityValues.toArray(new String [visiblityValues.size()]); 504 }else if(BORDER_STYLE.equals(cssProperty)){ 505 return (String []) borderStyleValues.toArray(new String [borderStyleValues.size()]); 506 } 507 return new String [0]; 508 } 509 510 public static String [] getCssLengthUnits() { 511 return (String []) cssLengthUnits.toArray(new String [cssLengthUnits.size()]); 512 } 513 514 public static String [] getColorValues() { 515 return (String []) colorValues.toArray(new String [colorValues.size()]); 516 } 517 518 public static Map getColorNameHexMap() { 519 return Collections.unmodifiableMap(colorNameHexMap); 520 } 521 522 public static String [] getFontFamilyValues() { 523 return (String []) fontFamilyValues.toArray(new String [fontFamilyValues.size()]); 524 } 525 526 public static String [] getWebFontValues() { 527 return (String []) webFontValues.toArray(new String [webFontValues.size()]); 528 } 529 530 public static String [] getFontFamilySetValues() { 531 return (String []) fontFamiliySetValues.toArray(new String [fontFamiliySetValues.size()]); 532 } 533 534 public static String [] getFontSizeValues() { 535 return (String []) fontSizeValues.toArray(new String [fontSizeValues.size()]); 536 } 537 } 538 | Popular Tags |