@Test public void percentage() throws OfxAuthoringException { width.setUnit("percentage"); width.setValue(12); String expected = "0.12\\linewidth"; String actual = lwc.buildWidth(width); Assert.assertEquals(expected, actual); }
public String buildWidth(Width width) throws OfxAuthoringException { if(!width.isSetValue()){throw new OfxAuthoringException("No width-value given");} StringBuffer sb = new StringBuffer(); if(!width.isSetUnit()){width.setUnit("cm");} if(width.getUnit().equals("cm")) { sb.append(width.getValue()); sb.append(width.getUnit()); } else if(width.getUnit().equals("percentage")) { sb.append(df.format(width.getValue()/100)); sb.append("\\linewidth"); } else { throw new OfxAuthoringException("No valid width"); } return sb.toString(); }
LatexWidthCalculator { public String buildWidth(Width width) throws OfxAuthoringException { if(!width.isSetValue()){throw new OfxAuthoringException("No width-value given");} StringBuffer sb = new StringBuffer(); if(!width.isSetUnit()){width.setUnit("cm");} if(width.getUnit().equals("cm")) { sb.append(width.getValue()); sb.append(width.getUnit()); } else if(width.getUnit().equals("percentage")) { sb.append(df.format(width.getValue()/100)); sb.append("\\linewidth"); } else { throw new OfxAuthoringException("No valid width"); } return sb.toString(); } }
LatexWidthCalculator { public String buildWidth(Width width) throws OfxAuthoringException { if(!width.isSetValue()){throw new OfxAuthoringException("No width-value given");} StringBuffer sb = new StringBuffer(); if(!width.isSetUnit()){width.setUnit("cm");} if(width.getUnit().equals("cm")) { sb.append(width.getValue()); sb.append(width.getUnit()); } else if(width.getUnit().equals("percentage")) { sb.append(df.format(width.getValue()/100)); sb.append("\\linewidth"); } else { throw new OfxAuthoringException("No valid width"); } return sb.toString(); } LatexWidthCalculator(); }
LatexWidthCalculator { public String buildWidth(Width width) throws OfxAuthoringException { if(!width.isSetValue()){throw new OfxAuthoringException("No width-value given");} StringBuffer sb = new StringBuffer(); if(!width.isSetUnit()){width.setUnit("cm");} if(width.getUnit().equals("cm")) { sb.append(width.getValue()); sb.append(width.getUnit()); } else if(width.getUnit().equals("percentage")) { sb.append(df.format(width.getValue()/100)); sb.append("\\linewidth"); } else { throw new OfxAuthoringException("No valid width"); } return sb.toString(); } LatexWidthCalculator(); String buildWidth(Width width); String buildHeight(Height height); }
LatexWidthCalculator { public String buildWidth(Width width) throws OfxAuthoringException { if(!width.isSetValue()){throw new OfxAuthoringException("No width-value given");} StringBuffer sb = new StringBuffer(); if(!width.isSetUnit()){width.setUnit("cm");} if(width.getUnit().equals("cm")) { sb.append(width.getValue()); sb.append(width.getUnit()); } else if(width.getUnit().equals("percentage")) { sb.append(df.format(width.getValue()/100)); sb.append("\\linewidth"); } else { throw new OfxAuthoringException("No valid width"); } return sb.toString(); } LatexWidthCalculator(); String buildWidth(Width width); String buildHeight(Height height);  }