Package org.freeplane.features.format

Examples of org.freeplane.features.format.FormattedObject


                                   Object transformedExtension) {
        if (obj instanceof FormattedFormula) {
            final FormattedFormula formattedFormula = (FormattedFormula) obj;
            final Object evaluationResult = transformContent(textController, formattedFormula.getObject(), node,
                transformedExtension);
            return new FormattedObject(evaluationResult, formattedFormula.getPattern());
        }
        if (!(obj instanceof String)) {
            return obj;
        }
        if (textController.isTextFormattingDisabled(node))
View Full Code Here


    Locale.setDefault(new Locale("en"));
  }

  @Test
  public void testBasics() {
    assertEquals("wrong formatting", "x: bla", new FormattedObject("bla", "x: %s").toString());
    assertEquals("wrong formatting", "x: 1.1234", new FormattedObject(1.1234, "x: %s").toString());
    assertEquals("wrong formatting", "1.12", new FormattedObject(1.1234, "%.2f").toString());
    assertEquals("wrong formatting", "1.12", new FormattedObject(1.1234, "#.##").toString());
  }
View Full Code Here

 
  @Test
  public void testNestedIFormattedObject() {
    double number = 1.123456;
    final FormattedNumber formattedNumber = new FormattedNumber(number, "#.##");
    final FormattedObject formattedObject  = new FormattedObject(formattedNumber, "x: %s");
    assertEquals("wrong pattern", "x: %s", formattedObject.getPattern());
    assertEquals("wrong formatting", "x: 1.12", formattedObject.toString());
  }
View Full Code Here

    assertEquals("wrong formatting", "x: 1.12", formattedObject.toString());
  }

  @Test
  public void testLocaleDependence() {
    final FormattedObject formattedObject = new FormattedObject(1.1234, "%.3f");
    assertEquals("wrong formatting", "1.123", formattedObject.toString());
    Locale.setDefault(new Locale("de"));
    // the format is evaluated only once
    assertEquals("no support for on-the-fly-changes of locale", "1.123", formattedObject.toString());
    // FormattedObject does not caches the formats
    assertEquals("formatting should be locale dependent", "1,123", new FormattedObject(1.1234, "%.3f").toString());
  }
View Full Code Here

  }

  @Test
  public void testSerializeNumber() {
    double number = 1.123456;
    final FormattedObject formattedObject = new FormattedObject(number, "#.##");
    final String serialized = "java.lang.Double|1.123456|number:decimal:#.##";
    assertEquals(serialized, FormattedObject.serialize(formattedObject));
    assertEquals("failure in deserialization", formattedObject, FormattedObject.deserialize(serialized));
  }
View Full Code Here

  }
 
  @Test
  public void testSerializeString() {
    String unformattedString = "\"sdf\"|sdf|sdf|: %s";
    final FormattedObject formattedObject = new FormattedObject(unformattedString, "|\"x\"|: %s");
    final String serialized = ""sdf"|sdf|sdf|: %s|string:formatter:|"x"|: %s";
    assertEquals(serialized, FormattedObject.serialize(formattedObject));
    assertEquals("failure in deserialization", formattedObject, FormattedObject.deserialize(serialized));
  }
View Full Code Here

  }
 
  @Test
  public void testStrangeInput() {
    final FormattedDate date = new FormattedDate(new Date(), "yyyy-mm-dd");
    final FormattedObject formattedObject = new FormattedObject(date, "#.##");
    assertEquals("decimal format is not applicable to date", date.toString(), formattedObject.toString());
  }
View Full Code Here

TOP

Related Classes of org.freeplane.features.format.FormattedObject

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.