Package net.mindengine.galen.specs

Examples of net.mindengine.galen.specs.Range


        Rect mainArea = mainObject.getArea();
        Rect secondArea = secondObject.getArea();
        int offset = getOffset(mainArea, secondArea);
       
       
        Range range = convertRange(spec.getRange(), pageValidation);
       
        if (!range.holds(offset)) {
          throw new ValidationErrorException().withMessage(
              String.format("\"%s\" is %dpx %s \"%s\" %s",
                  objectName,
                  offset,
                  direction.toString(),
View Full Code Here


       
        checkAvailability(mainObject, objectName);
       
        int realValue = getSizeValue(mainObject);
       
        Range range = convertRange(spec.getRange(), pageValidation);
       
        if (!range.holds(realValue)) {
                throw new ValidationErrorException()
                    .withErrorArea(new ErrorArea(mainObject.getArea(), objectName))
                    .withMessage(format("\"%s\" %s is %dpx %s", objectName, getUnitName(), realValue, range.getErrorMessageSuffix()));
        }
    }
View Full Code Here

        return buffer.toString();
    }

    protected String verifyLocation(Rect mainArea, Rect secondArea, Location location, PageValidation pageValidation, T spec) {
        List<String> messages = new LinkedList<String>();
        Range range;
       
        try {
            range = pageValidation.convertRange(location.getRange());
        }
        catch (Exception ex) {
            return format("Cannot convert range: " + ex.getMessage());
        }
       
        for (Side side : location.getSides()) {
            int offset = getOffsetForSide(mainArea, secondArea, side, spec);
            if (!range.holds(offset)) {
                messages.add(format("%dpx %s", offset, side));
            }
        }
       
        if (messages.size() > 0) {
            StringBuffer buffer = new StringBuffer();
            boolean comma = false;
            for (String message : messages) {
                if (comma) {
                    buffer.append(" and ");
                }
                buffer.append(message);
                comma = true;
            }
           
            buffer.append(' ');
            buffer.append(range.getErrorMessageSuffix());
            return buffer.toString();
        }
        else return null;
    }
View Full Code Here

        }
        if (text.equals("%")) {
            return createRange(firstValue, rangeType).withPercentOf(readPercentageOf(reader));
        }
        else if (rangeType == RangeType.NOTHING){
            Range range;

            if (text.equals("to")) {
                Double secondValue =  new ExpectNumber().read(reader);
                range = Range.between(firstValue, secondValue);
            }
            else {
                throw new SyntaxException(UNKNOWN_LINE, "Expecting \"px\", \"to\" or \"%\", got \"" + text + "\"");
            }
           
            String end = expectNonNumeric(reader);
            if (end.equals(endingWord)) {
                return range;
            }
            else if (end.equals("%")) {
                return range.withPercentOf(readPercentageOf(reader));
            }
            else throw new SyntaxException(UNKNOWN_LINE, "Missing ending: \"px\" or \"%\"");
        }
        else throw new SyntaxException(UNKNOWN_LINE, msgFor(text));
    }
View Full Code Here

        expectRange.setEndingWord("%");
       
        List<ColorRange> colorRanges = new LinkedList<ColorRange>();
        while(reader.hasMore()) {
           
            Range range = expectRange.read(reader);
           
            String colorText = reader.readUntilSymbol(',').trim();
           
            if (colorText.isEmpty()) {
                throw new SyntaxException("No color defined");
View Full Code Here

    @Override
    public List<Location> read(StringCharReader reader) {
       
        List<Location> locations = new LinkedList<Location>();
        while(reader.hasMore()) {
            Range range = range().read(reader);
            List<Side> sides = Expectations.sides().read(reader);
           
            locations.add(new Location(range, sides));
            if (reader.currentSymbol() == ',') {
                reader.next();
View Full Code Here

                }
                if (valueB != null) {
                    valueB = valueB * value / 100.0;
                }
               
                return new Range(valueA, valueB).withType(range.getRangeType());
            }
            else throw new SyntaxException(UNKNOWN_LINE, format("Locator for object \"%s\" is not specified", objectName));
        }
        else throw new SyntaxException(UNKNOWN_LINE, format("Value path is incorrect %s", valuePath));
    }
View Full Code Here

        GalenConfig config = GalenConfig.getConfig();
        System.setProperty("galen.range.approximation", "5");
        config.reset();
       
        StringCharReader reader = new StringCharReader("~ 20 px");
        Range range = Expectations.range().read(reader);
       
        assertThat(range, is(Range.between(15, 25)));
       
        deleteSystemProperty("galen.range.approximation");
    }
View Full Code Here

    }

    @Test(dataProvider = "rangeTestData")
    public void expectRangeTest(String textForParsing, Range expected) {
        StringCharReader stringCharReader = new StringCharReader(textForParsing);
        Range range = new ExpectRange().read(stringCharReader);
        MatcherAssert.assertThat(range, is(expected));
    }
View Full Code Here

TOP

Related Classes of net.mindengine.galen.specs.Range

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.