当前位置: 首页>>代码示例>>Java>>正文


Java ECSSVersion.CSS30属性代码示例

本文整理汇总了Java中com.helger.css.ECSSVersion.CSS30属性的典型用法代码示例。如果您正苦于以下问题:Java ECSSVersion.CSS30属性的具体用法?Java ECSSVersion.CSS30怎么用?Java ECSSVersion.CSS30使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.helger.css.ECSSVersion的用法示例。


在下文中一共展示了ECSSVersion.CSS30属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testWriteCertainRules

@Test
public void testWriteCertainRules ()
{
  final CSSWriterSettings aSettings = new CSSWriterSettings (ECSSVersion.CSS30, true);
  aSettings.setWriteFontFaceRules (false);
  aSettings.setWriteKeyframesRules (false);
  aSettings.setWriteMediaRules (false);
  aSettings.setWritePageRules (false);
  final CSSWriter aWriter = new CSSWriter (aSettings).setWriteHeaderText (false);

  // Some non-special rules
  CascadingStyleSheet aCSS = CSSReader.readFromString (CSS3, ECSSVersion.CSS30);
  assertNotNull (aCSS);
  assertEquals ("h1{color:red;margin:1px}h2{color:rgb(1,2,3)}h3{}", aWriter.getCSSAsString (aCSS));

  // Only @media rule
  aCSS = CSSReader.readFromString (CSS4, ECSSVersion.CSS30);
  assertNotNull (aCSS);
  assertEquals ("", aWriter.getCSSAsString (aCSS));

  // Nothing special
  aCSS = CSSReader.readFromString (CSS5, ECSSVersion.CSS30);
  assertNotNull (aCSS);
  assertEquals ("h1{color:red;margin:1px}h2{color:red;margin:1px}", aWriter.getCSSAsString (aCSS));
}
 
开发者ID:phax,项目名称:ph-css,代码行数:25,代码来源:CSSWriterTest.java

示例2: writeCSS30

/**
 * Write a CSS 3.0 declaration to a file using UTF-8 encoding.
 *
 * @param aCSS
 *        The CSS to be written to a file. May not be <code>null</code>.
 * @param aFile
 *        The file to be written. May not be <code>null</code>.
 * @return {@link ESuccess#SUCCESS} if everything went okay, and
 *         {@link ESuccess#FAILURE} if an error occurred
 */
public ESuccess writeCSS30 (final CascadingStyleSheet aCSS, final File aFile)
{
  // 1.param: version to write
  // 2.param: false== non-optimized output
  final CSSWriterSettings aSettings = new CSSWriterSettings (ECSSVersion.CSS30, false);
  try
  {
    final CSSWriter aWriter = new CSSWriter (aSettings);
    // Write the @charset rule: (optional)
    aWriter.setContentCharset (StandardCharsets.UTF_8.name ());
    // Write a nice file header
    aWriter.setHeaderText ("This file was generated by phloc-css\nGrab a copy at http://code.google.com/p/phloc-css");
    // Convert the CSS to a String
    final String sCSSCode = aWriter.getCSSAsString (aCSS);
    // Finally write the String to a file
    return SimpleFileIO.writeFile (aFile, sCSSCode, StandardCharsets.UTF_8);
  }
  catch (final Exception ex)
  {
    s_aLogger.error ("Failed to write the CSS to a file", ex);
    return ESuccess.FAILURE;
  }
}
 
开发者ID:phax,项目名称:ph-css,代码行数:33,代码来源:WikiWriteCSS.java

示例3: testBasic

@Test
public void testBasic ()
{
  final CSSWriterSettings aSettings = new CSSWriterSettings (ECSSVersion.CSS30, false);
  final CSSHSL aColor = new CSSHSL (1, 2, 3);
  assertEquals ("hsl(1,2%,3%)", aColor.getAsCSSString (aSettings));

  CommonsTestHelper.testDefaultImplementationWithEqualContentObject (aColor, new CSSHSL (aColor));
  CommonsTestHelper.testDefaultImplementationWithEqualContentObject (aColor, new CSSHSL (1, 2, 3));
  CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (aColor, new CSSHSL (0, 2, 3));
  CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (aColor, new CSSHSL (1, 0, 3));
  CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (aColor, new CSSHSL (1, 2, 0));
}
 
开发者ID:phax,项目名称:ph-css,代码行数:13,代码来源:CSSHSLTest.java

示例4: testAll

@Test
public void testAll ()
{
  final CSSWriter aWriter = new CSSWriter (ECSSVersion.CSS30);
  for (final ECSSColor eColor : ECSSColor.values ())
  {
    assertTrue (StringHelper.hasText (eColor.getName ()));
    assertTrue (CSSColorHelper.isColorValue (eColor.getName ()));

    final String sHex = eColor.getAsHexColorValue ();
    assertTrue (sHex, CSSColorHelper.isHexColorValue (sHex));

    final String sRGB = eColor.getAsRGBColorValue ();
    assertTrue (sRGB, CSSColorHelper.isRGBColorValue (sRGB));
    assertNotNull (eColor.getAsRGB ());
    assertEquals (sRGB, aWriter.getCSSAsString (eColor.getAsRGB ()));

    final String sRGBA = eColor.getAsRGBAColorValue (1f);
    assertTrue (sRGBA, CSSColorHelper.isRGBAColorValue (sRGBA));
    assertNotNull (eColor.getAsRGBA (1));
    assertEquals (sRGBA, aWriter.getCSSAsString (eColor.getAsRGBA (1)));

    final String sHSL = eColor.getAsHSLColorValue ();
    assertTrue (sHSL, CSSColorHelper.isHSLColorValue (sHSL));
    assertNotNull (eColor.getAsHSL ());
    assertEquals (sHSL, aWriter.getCSSAsString (eColor.getAsHSL ()));

    final String sHSLA = eColor.getAsHSLAColorValue (1f);
    assertTrue (sHSLA, CSSColorHelper.isHSLAColorValue (sHSLA));
    assertNotNull (eColor.getAsHSLA (1));
    assertEquals (sHSLA, aWriter.getCSSAsString (eColor.getAsHSLA (1)));

    assertSame (eColor, ECSSColor.getFromNameCaseInsensitiveOrNull (eColor.getName ()));
    assertTrue (ECSSColor.isDefaultColorName (eColor.getName ()));
  }
}
 
开发者ID:phax,项目名称:ph-css,代码行数:36,代码来源:ECSSColorTest.java

示例5: testBasic

@Test
public void testBasic ()
{
  final CSSWriterSettings aSettings = new CSSWriterSettings (ECSSVersion.CSS30, false);
  final CSSRGBA aColor = new CSSRGBA (1, 2, 3, 0.5f);
  assertEquals ("rgba(1,2,3,0.5)", aColor.getAsCSSString (aSettings));

  CommonsTestHelper.testDefaultImplementationWithEqualContentObject (aColor, new CSSRGBA (aColor));
  CommonsTestHelper.testDefaultImplementationWithEqualContentObject (aColor, new CSSRGBA (1, 2, 3, 0.5f));
  CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (aColor, new CSSRGBA (0, 2, 3, 0.5f));
  CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (aColor, new CSSRGBA (1, 0, 3, 0.5f));
  CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (aColor, new CSSRGBA (1, 2, 0, 0.5f));
  CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (aColor, new CSSRGBA (1, 2, 3, 0f));
}
 
开发者ID:phax,项目名称:ph-css,代码行数:14,代码来源:CSSRGBATest.java

示例6: testReadSpecialGood

@Test
public void testReadSpecialGood ()
{
  final ECSSVersion eVersion = ECSSVersion.CSS30;
  final Charset aCharset = StandardCharsets.UTF_8;
  final File aFile = new File ("src/test/resources/testfiles/css21/good/artificial/test-url.css");
  final CascadingStyleSheet aCSS = CSSReader.readFromFile (aFile, aCharset, eVersion);
  assertNotNull (aCSS);

  final String sCSS = new CSSWriter (eVersion, false).getCSSAsString (aCSS);
  assertNotNull (sCSS);
  if (false)
    s_aLogger.info (sCSS);
}
 
开发者ID:phax,项目名称:ph-css,代码行数:14,代码来源:CSSReader21SpecialFuncTest.java

示例7: testBasic

@Test
public void testBasic ()
{
  final CSSURI aURI = new CSSURI ("a.gif");
  assertEquals ("a.gif", aURI.getURI ());
  final CSSWriterSettings aSettings = new CSSWriterSettings (ECSSVersion.CSS30, false);
  assertEquals ("url(a.gif)", aURI.getAsCSSString (aSettings));
  aSettings.setQuoteURLs (true);
  assertEquals ("url('a.gif')", aURI.getAsCSSString (aSettings));
  assertFalse (aURI.isDataURL ());
  assertNull (aURI.getAsDataURL ());

  CommonsTestHelper.testDefaultImplementationWithEqualContentObject (aURI, new CSSURI ("a.gif"));
  CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (aURI, new CSSURI ("b.gif"));
}
 
开发者ID:phax,项目名称:ph-css,代码行数:15,代码来源:CSSURITest.java

示例8: getMinimumCSSVersion

@Nonnull
public ECSSVersion getMinimumCSSVersion ()
{
  if (m_aMembers.containsAny (m -> m instanceof CSSPageMarginBlock))
    return ECSSVersion.CSS30;
  return ECSSVersion.CSS21;
}
 
开发者ID:phax,项目名称:ph-css,代码行数:7,代码来源:CSSPageRule.java

示例9: testCreate

@Test
public void testCreate ()
{
  final CSSImportRule aImportRule = new CSSImportRule ("a.gif");
  final CSSWriterSettings aSettings = new CSSWriterSettings (ECSSVersion.CSS30, false);
  assertEquals ("@import url(a.gif);\n", aImportRule.getAsCSSString (aSettings));
  aSettings.setQuoteURLs (true);
  assertEquals ("@import url('a.gif');\n", aImportRule.getAsCSSString (aSettings));
}
 
开发者ID:phax,项目名称:ph-css,代码行数:9,代码来源:CSSImportRuleTest.java

示例10: testReadSpecialGood

@Test
public void testReadSpecialGood ()
{
  final ECSSVersion eVersion = ECSSVersion.CSS30;
  final Charset aCharset = StandardCharsets.UTF_8;
  final File aFile = new File ("src/test/resources/testfiles/css30/good/artificial/hacks2.css");
  final CascadingStyleSheet aCSS = CSSReader.readFromFile (aFile, aCharset, eVersion);
  assertNotNull (aCSS);

  final String sCSS = new CSSWriter (eVersion, false).getCSSAsString (aCSS);
  assertNotNull (sCSS);
  if (false)
    m_aLogger.info (sCSS);
}
 
开发者ID:phax,项目名称:ph-css,代码行数:14,代码来源:CSSReader30FuncTest.java

示例11: testReadSpecialGood

@Test
public void testReadSpecialGood ()
{
  final ECSSVersion eVersion = ECSSVersion.CSS30;
  final Charset aCharset = StandardCharsets.UTF_8;
  final File aFile = new File ("src/test/resources/testfiles/css30/good/artificial/test-postcss-cssnext.css");
  final CascadingStyleSheet aCSS = CSSReader.readFromFile (aFile, aCharset, eVersion);
  assertNotNull (aCSS);

  final String sCSS = new CSSWriter (eVersion, false).getCSSAsString (aCSS);
  assertNotNull (sCSS);
  if (false)
    s_aLogger.info (sCSS);
}
 
开发者ID:phax,项目名称:ph-css,代码行数:14,代码来源:CSSReader30SpecialFuncTest.java

示例12: getMinimumCSSVersion

@Nonnull
public ECSSVersion getMinimumCSSVersion ()
{
  return ECSSVersion.CSS30;
}
 
开发者ID:phax,项目名称:ph-css,代码行数:5,代码来源:CSSViewportRule.java


注:本文中的com.helger.css.ECSSVersion.CSS30属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。