• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ParsedValue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javafx.css.ParsedValue的典型用法代码示例。如果您正苦于以下问题:Java ParsedValue类的具体用法?Java ParsedValue怎么用?Java ParsedValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: resolveRoot

import javafx.css.ParsedValue; //导入依赖的package包/类
private void resolveRoot(Stylesheet css) {
  css.getRules().stream()
      .filter(r -> r.getSelectors().stream()
          .map(Selector::toString)
          .map(String::trim)
          .filter(s -> s.equals(ROOT))
          .findAny()
          .isPresent())
      .flatMap(r -> r.getDeclarations().stream())
      .forEach(d -> {
        ParsedValue<?, ?> pv = d.getParsedValue();
        ParsedValue<?, ?> resolve = resolve(pv);
        if (classifyValue(resolve.getValue(), d.getProperty(), d.getParsedValue()) == false) {
          classifyValue(resolve.convert(FONT), d.getProperty(), Util.createParsedValue(() -> resolve(pv).convert(FONT)));
        }
      });
}
 
开发者ID:XDean,项目名称:CSS-Editor-FX,代码行数:18,代码来源:CSSContext.java


示例2: convert

import javafx.css.ParsedValue; //导入依赖的package包/类
/**
 * Converts the given CSS function call to a Java object.
 *
 * @param value ParsedValue containing the function call
 * @param font Font used for functions that depend on the font size
 * @return The result of the function call as a Java object or null if function call failed
 */
@Override
public Size convert(ParsedValue<String, Size> value, Font font) {
    Matcher matcher = this.getMatcher(value.getValue(), REGEX);

    // nonsensical input
    if (matcher == null) {
        return null;
    }

    BufferedImage reader;
    try {
        File file = new File(matcher.group(1));
        reader = ImageIO.read(file);
    } catch (IOException e) {
        //e.printStackTrace();
        return null;
    }

    return new Size(reader.getHeight(), SizeUnits.PX);
}
 
开发者ID:guigarage,项目名称:LessFX,代码行数:28,代码来源:ImageHeightConverter.java


示例3: convert

import javafx.css.ParsedValue; //导入依赖的package包/类
/**
 * Converts the given CSS function call to a Java object.
 *
 * @param value ParsedValue containing the function call
 * @param font Font used for functions that depend on the font size
 * @return The result of the function call as a Java object or null if function call failed
 */
@Override
public Color convert(ParsedValue<String, Color> value, Font font) {
    Matcher matcher = getMatcher(value.getValue(), REGEX);

    // nonsensical input
    if (matcher == null) {
        return null;
    }

    double color[] = new double[3];

    for (int i = 1; i <= 3; i++) {
        String group = matcher.group(i);
        if (group.charAt(group.length() - 1) == '%') { // value given in percentage
            color[i-1] = Double.valueOf(group.substring(0, group.length() - 1)) / 100;
        } else { // value given in unsigned 8bit integers
            color[i-1] = Double.valueOf(group) / 255;
        }
        if (color[i-1] > 1.0) {
            return null;
        }
    }

    return new Color(color[0], color[1], color[2], 1.0);
}
 
开发者ID:guigarage,项目名称:LessFX,代码行数:33,代码来源:RGBConverter.java


示例4: convert

import javafx.css.ParsedValue; //导入依赖的package包/类
/**
 * Converts the given CSS function call to a Java object.
 *
 * @param value ParsedValue containing the function call
 * @param font Font used for functions that depend on the font size
 * @return The result of the function call as a Java object or null if function call failed
 */
@Override
public Boolean convert(ParsedValue<String, Boolean> value, Font font) {
    Matcher matcher = getMatcher(value.getValue(), REGEX1);

    if (matcher == null) {
        return false;
    }

    try {
        if (Color.web(matcher.group(1)) != null) {
            return true;
        } else {
            matcher = getMatcher(matcher.group(1), REGEX2);
            return matcher != null;
        }
    } catch (IllegalArgumentException e) {
        return false;
    }
}
 
开发者ID:guigarage,项目名称:LessFX,代码行数:27,代码来源:IsColorConverter.java


示例5: classifyValue

import javafx.css.ParsedValue; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private boolean classifyValue(Object classObject, String key, ParsedValue<?, ?> value) {
  if (classObject instanceof Paint) {
    paints.put(key, (ParsedValue<?, Paint>) value);
    return true;
  }
  return false;
}
 
开发者ID:XDean,项目名称:CSS-Editor-FX,代码行数:9,代码来源:CSSContext.java


示例6: resolve

import javafx.css.ParsedValue; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public <V, T> ParsedValue<V, T> resolve(ParsedValue<V, T> pv) {
  try {
    if (pv instanceof ParsedValueImpl) {
      ParsedValueImpl<V, T> pvi = (ParsedValueImpl<V, T>) pv;
      if (pvi.isContainsLookups() == false) {
        return pv;
      } else if (pvi.isLookup()) {
        T lookup = lookup(pv.getValue());
        // System.out.printf("lookup %s find %s\n", pv.getValue(), lookup);
        return Util.createParsedValue(lookup);
      } else {
        V value = pv.getValue();
        if (value instanceof ParsedValue) {
          return new ParsedValueImpl<V, T>((V) resolve((ParsedValue<?, ?>) value), pv.getConverter());
        } else if (value instanceof ParsedValue[]) {
          ParsedValue[] originPvs = (ParsedValue[]) value;
          ParsedValue[] pvs = new ParsedValue[originPvs.length];
          for (int i = 0; i < pvs.length; i++) {
            pvs[i] = resolve(originPvs[i]);
          }
          return new ParsedValueImpl<V, T>((V) pvs, pv.getConverter());
        }
      }
    }
  } catch (ClassCastException e) {
    return pv;
  }
  return pv;
}
 
开发者ID:XDean,项目名称:CSS-Editor-FX,代码行数:31,代码来源:CSSContext.java


示例7: testPixel

import javafx.css.ParsedValue; //导入依赖的package包/类
@Override
public void testPixel() {
    String input = "isunit(1px, px)";
    ParsedValue<String, Boolean> value = new ParsedValueImpl<>(input, converter);
    boolean result = converter.convert(value, null);

    assertTrue("Pixel", result);
}
 
开发者ID:guigarage,项目名称:LessFX,代码行数:9,代码来源:IsUnitConverterTest.java


示例8: convert

import javafx.css.ParsedValue; //导入依赖的package包/类
/**
 * Converts the given CSS function call to a Java object.
 *
 * @param value ParsedValue containing the function call
 * @param font Font used for functions that depend on the font size
 * @return The result of the function call as a Java object or null if function call failed
 */
@Override
public Number convert(ParsedValue<String, Number> value, Font font) {
    Matcher matcher = getMatcher(value.getValue(), REGEX);

    // nonsensical input
    if (matcher == null) {
        return null;
    } else if (matcher.group(1).equals("")) {
        return null;
    }

    return Math.asin(Double.parseDouble(matcher.group(1)));
}
 
开发者ID:guigarage,项目名称:LessFX,代码行数:21,代码来源:ArcSinusConverter.java


示例9: testNegDouble

import javafx.css.ParsedValue; //导入依赖的package包/类
@Override
public void testNegDouble() {
    String input = "cos(-3.14159)";
    ParsedValue<String, Number> value = new ParsedValueImpl<>(input, converter);
    Number result = converter.convert(value, null);

    assertNotNull(result);
    assertEquals(Math.cos(-3.14159), result.doubleValue(), 0.0001);
}
 
开发者ID:guigarage,项目名称:LessFX,代码行数:10,代码来源:CosineConverterTest.java


示例10: testString

import javafx.css.ParsedValue; //导入依赖的package包/类
@Override
public void testString() {
    String input = "iscolor(\"String!\")";
    ParsedValue<String, Boolean> value = new ParsedValueImpl<>(input, converter);
    boolean result = converter.convert(value, null);

    assertFalse("String", result);
}
 
开发者ID:guigarage,项目名称:LessFX,代码行数:9,代码来源:IsColorConverterTest.java


示例11: testPercentage

import javafx.css.ParsedValue; //导入依赖的package包/类
@Override
public void testPercentage() {
    String input = "hsla(180, 50%, 50%, 50%)";
    ParsedValue<String, Color> value = new ParsedValueImpl<>(input, converter);
    Color result = converter.convert(value, null);

    assertNotNull("% not null", result);
    assertEquals("R %", (double)63 / 255, result.getRed(), 0.01);
    assertEquals("G %", (double)191 / 255, result.getGreen(), 0.01);
    assertEquals("B %", (double)191 / 255, result.getBlue(), 0.01);
    assertEquals("alpha %", 0.5, result.getOpacity(), 0.01);
}
 
开发者ID:guigarage,项目名称:LessFX,代码行数:13,代码来源:HSLAConverterTest.java


示例12: testEmptyParam

import javafx.css.ParsedValue; //导入依赖的package包/类
@Override
public void testEmptyParam() {
    String input = "color()";
    ParsedValue<String, Color> value = new ParsedValueImpl<>(input, converter);
    Color result = converter.convert(value, null);

    assertNull(result);
}
 
开发者ID:guigarage,项目名称:LessFX,代码行数:9,代码来源:ColorConverterTest.java


示例13: convert

import javafx.css.ParsedValue; //导入依赖的package包/类
/**
 * Converts the given CSS function call to a Java object.
 *
 * @param value ParsedValue containing the function call
 * @param font Font used for functions that depend on the font size
 * @return The result of the function call as a Java object or null if function call failed
 */
@Override
public String convert(ParsedValue<String, String> value, Font font) {
    Matcher matcher = this.getMatcher(value.getValue(), REGEX);

    // nonsensical input
    if (matcher == null) {
        return null;
    }
    Double val = Double.valueOf(matcher.group(1)) * 100;
    return new DecimalFormat("#.######").format(val) + "%";
}
 
开发者ID:guigarage,项目名称:LessFX,代码行数:19,代码来源:PercentageConverter.java


示例14: testNaN

import javafx.css.ParsedValue; //导入依赖的package包/类
@Override
public void testNaN() {
    String input = "floor(not a number!)";
    ParsedValue<String, Integer> value = new ParsedValueImpl<>(input, converter);
    Integer result = converter.convert(value, null);

    assertNull(result);
}
 
开发者ID:guigarage,项目名称:LessFX,代码行数:9,代码来源:FloorConverterTest.java


示例15: convert

import javafx.css.ParsedValue; //导入依赖的package包/类
/**
 * Converts the given CSS function call to a Java object.
 * 
 * @param value ParsedValue containing the function call
 * @param font Font used for functions that depend on the font size
 * @return The result of the function call as a Java object or null if function call failed
 */
@Override
public Number convert(ParsedValue<String, Number> value, Font font) {
    Matcher matcher = this.getMatcher(value.getValue(), REGEX1);

    if (matcher == null) {
        return null;
    }

    // The parameters of the function
    String numbers = matcher.group(1);

    // setting the initial value to the smallest possible double value to ensure that the first parameter is
    // also the first one the others are compared to
    double max = Double.NEGATIVE_INFINITY;

    // matcher for the parameters. It matches the parameter one by one
    matcher = this.getMatcher(numbers, REGEX2);

    // check if parameter list isn't invalid.
    if (matcher == null) {
        return null;
    }

    do {
        // get parameter as string
        String stringValue = matcher.group(1);

        // convert to double
        double val = Double.parseDouble(stringValue);

        // check if above last found maximum
        if (val > max) max = val;
    } while (matcher.find()); // check for next parameter

    return max;
}
 
开发者ID:guigarage,项目名称:LessFX,代码行数:44,代码来源:MaxConverter.java


示例16: testInteger

import javafx.css.ParsedValue; //导入依赖的package包/类
@Override
public void testInteger() {
    String input = "color(1)";
    ParsedValue<String, Color> value = new ParsedValueImpl<>(input, converter);
    Color result = converter.convert(value, null);

    assertNull(result);
}
 
开发者ID:guigarage,项目名称:LessFX,代码行数:9,代码来源:ColorConverterTest.java


示例17: convert

import javafx.css.ParsedValue; //导入依赖的package包/类
/**
 * Converts the given CSS function call to a Java object.
 *
 * @param value ParsedValue containing the function call
 * @param font Font used for functions that depend on the font size
 * @return The result of the function call as a Java object or null if function call failed
 */
@Override
public Integer convert(ParsedValue<String, Integer> value, Font font) {
    Matcher matcher = this.getMatcher(value.getValue(), REGEX);
    Number val;

    // nonsensical input
    if (matcher == null) {
        return null;
    } else {
        val = new Double(matcher.group(1));
    }
    // LessCSS reference says that "ceil()" is returning an integer unlike Java
    return (int)Math.ceil(val.doubleValue());
}
 
开发者ID:guigarage,项目名称:LessFX,代码行数:22,代码来源:CeilConverter.java


示例18: testNeg1Double

import javafx.css.ParsedValue; //导入依赖的package包/类
@Test
public void testNeg1Double() {
    String input = "pow(-3.2, 2.2)";
    ParsedValue<String, Size> value = new ParsedValueImpl<>(input, converter);
    Size result = converter.convert(value, null);

    assertNull(result);
}
 
开发者ID:guigarage,项目名称:LessFX,代码行数:9,代码来源:PowConverterTest.java


示例19: testMissingParameters

import javafx.css.ParsedValue; //导入依赖的package包/类
@Override
public void testMissingParameters() {
    String input = "rgb(50%, 50%)";
    ParsedValue<String, Color> value = new ParsedValueImpl<>(input, converter);
    Color result = converter.convert(value, null);

    assertNull("Missing parameters", result);
}
 
开发者ID:guigarage,项目名称:LessFX,代码行数:9,代码来源:RGBConverterTest.java


示例20: testEmpty

import javafx.css.ParsedValue; //导入依赖的package包/类
@Override
public void testEmpty() {
    String input = "atan()";
    ParsedValue<String, Number> value = new ParsedValueImpl<>(input, converter);
    Number result = converter.convert(value, null);

    assertNull(result);
}
 
开发者ID:guigarage,项目名称:LessFX,代码行数:9,代码来源:ArcTanConverterTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CachingRecommender类代码示例发布时间:2022-05-23
下一篇:
Java Hash类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap