boolean identifiedInput = false; for (Unit unit : Unit.values()) { if (length.contains(unit.abbr())) { Double value = Double.valueOf(length.substring(0, length.indexOf(unit.abbr()))); newValue = Math.round(roundingFactor * value / destinationUnit.unitInMillimiter() * unit.mUnitInMillimiter) / roundingFactor; }else{ destinationUnit = unit; newLength = String.valueOf(newValue) + destinationUnit.abbr(); identifiedInput = true; break; LOG.warning("The unit " + length + " could not be transformed to " + destinationUnit.toString() + "!");
String vSpacingColumn = (new DecimalFormat("#0.###").format(spacing) + Unit.CENTIMETER.abbr()).replace(",", ".");
String vSpacingColumn = (new DecimalFormat("#0.###").format(spacing) + Unit.CENTIMETER.abbr()).replace(",", ".");
String vSpacingColumn = (new DecimalFormat("#0.###").format(spacing) + Unit.CENTIMETER.abbr()).replace(",", ".");
double roundingFactor = 10000.0; double inValue = Math.round(roundingFactor * width / Unit.INCH.unitInMillimiter()) / roundingFactor; String sWidthIN = String.valueOf(inValue) + Unit.INCH.abbr(); newWidthNextColumn = 0; inValue = Math.round(roundingFactor * newWidthNextColumn / Unit.INCH.unitInMillimiter()) / roundingFactor; sWidthIN = String.valueOf(inValue) + Unit.INCH.abbr(); column.getOdfElement().setProperty(OdfTableColumnProperties.ColumnWidth, sWidthIN); double relWidth = (DEFAULT_REL_TABLE_WIDTH / table.getWidth()) * newWidthNextColumn;
double roundingFactor = 10000.0; double inValue = Math.round(roundingFactor * width / Unit.INCH.unitInMillimiter()) / roundingFactor; String sWidthIN = String.valueOf(inValue) + Unit.INCH.abbr(); newWidthNextColumn = 0; inValue = Math.round(roundingFactor * newWidthNextColumn / Unit.INCH.unitInMillimiter()) / roundingFactor; sWidthIN = String.valueOf(inValue) + Unit.INCH.abbr(); column.getOdfElement().setProperty(OdfTableColumnProperties.ColumnWidth, sWidthIN); double relWidth = (DEFAULT_REL_TABLE_WIDTH / table.getWidth()) * newWidthNextColumn;
double roundingFactor = 10000.0; double inValue = Math.round(roundingFactor * width / Unit.INCH.unitInMillimiter()) / roundingFactor; String sWidthIN = String.valueOf(inValue) + Unit.INCH.abbr(); newWidthNextColumn = 0; inValue = Math.round(roundingFactor * newWidthNextColumn / Unit.INCH.unitInMillimiter()) / roundingFactor; sWidthIN = String.valueOf(inValue) + Unit.INCH.abbr(); column.getOdfElement().setProperty(OdfTableColumnProperties.ColumnWidth, sWidthIN); double relWidth = (DEFAULT_REL_TABLE_WIDTH / table.getWidth()) * newWidthNextColumn;
boolean identifiedInput = false; for (Unit unit : Unit.values()) { if (length.contains(unit.abbr())) { Double value = Double.valueOf(length.substring(0, length.indexOf(unit.abbr()))); newValue = Math.round(roundingFactor * value / destinationUnit.unitInMillimiter() * unit.mUnitInMillimiter) / roundingFactor; }else{ destinationUnit = unit; newLength = String.valueOf(newValue) + destinationUnit.abbr(); identifiedInput = true; break; LOG.warning("The unit " + length + " could not be transformed to " + destinationUnit.toString() + "!");
/** * Set the width of the column (in Millimeter). * @param width * the width that will be set to the column (in Millimeter). */ public void setWidth(long width) { String sWidthMM = String.valueOf(width) + Unit.MILLIMETER.abbr(); String sWidthIN = PositiveLength.mapToUnit(sWidthMM, Unit.INCH); splitRepeatedColumns(); maColumnElement.setProperty(OdfTableColumnProperties.ColumnWidth, sWidthIN); //check if need set relative width int index = getColumnIndex(); if (index >= 1) { index = index - 1; } else { index = index + 1; } OdfTableColumn column = null; if (index < getTable().getColumnCount()) { column = getTable().getColumnByIndex(index); } if (column != null) { long prevColumnRelWidth = column.getRelativeWidth(); if (prevColumnRelWidth != 0) { long prevColumnWidth = column.getWidth(); setRelativeWidth(prevColumnRelWidth / prevColumnWidth * width); } } }
double roundingFactor = 10000.0; double inValue = Math.round(roundingFactor * width / Unit.INCH.unitInMillimiter()) / roundingFactor; String sWidthIN = String.valueOf(inValue) + Unit.INCH.abbr(); mTableElement.setProperty(OdfTableProperties.Width, sWidthIN);
boolean identifiedInput = false; for (Unit unit : Unit.values()) { if (length.contains(unit.abbr())) { Double value = Double.valueOf(length.substring(0, length.indexOf(unit.abbr()))); newValue = Math.round(roundingFactor * value / destinationUnit.unitInMillimiter() * unit.mUnitInMillimiter) / roundingFactor; }else{ destinationUnit = unit; LOG.warning("The unit " + length + " could not be transformed to " + destinationUnit.toString() + "!");
boolean identifiedInput = false; for (Unit unit : Unit.values()) { if (length.contains(unit.abbr())) { Double value = Double.valueOf(length.substring(0, length.indexOf(unit.abbr()))); newValue = Math.round(roundingFactor * value / destinationUnit.unitInMillimiter() * unit.mUnitInMillimiter) / roundingFactor; }else{ destinationUnit = unit; newLength = String.valueOf(newValue) + destinationUnit.abbr(); identifiedInput = true; break; LOG.warning("The unit " + length + " could not be transformed to " + destinationUnit.toString() + "!");
double roundingFactor = 10000.0; double inValue = Math.round(roundingFactor * width / Unit.INCH.unitInMillimiter()) / roundingFactor; String sWidthIN = String.valueOf(inValue) + Unit.INCH.abbr(); mTableElement.setProperty(OdfTableProperties.Width, sWidthIN);
boolean identifiedInput = false; for (Unit unit : Unit.values()) { if (length.contains(unit.abbr())) { Double value = Double.valueOf(length.substring(0, length.indexOf(unit.abbr()))); newValue = Math.round(roundingFactor * value / destinationUnit.unitInMillimiter() * unit.mUnitInMillimiter) / roundingFactor; }else{ destinationUnit = unit; LOG.warning("The unit " + length + " could not be transformed to " + destinationUnit.toString() + "!");
/** * Set the width of the table (in Millimeter). * <p> * Throw an UnsupportedOperationException if the * table is part of a spreadsheet document that does not allow to change the table size, * because spreadsheet is not allow user to set the table size. * * @param width the width that need to set (in Millimeter). * <p> * An UnsupportedOperationException will be thrown if the table is in the spreadsheet document. */ public void setWidth(long width) { if (!mIsSpreadsheet) { String sWidthMM = String.valueOf(width) + Unit.MILLIMETER.abbr(); String sWidthIN = PositiveLength.mapToUnit(sWidthMM, Unit.INCH); mTableElement.setProperty(OdfTableProperties.Width, sWidthIN); //if the width is changed, we should also change the table:align properties if it is "margins" //otherwise the width seems not changed String alineStyle = mTableElement.getProperty(StyleTablePropertiesElement.Align); if (TableAlignAttribute.Value.MARGINS.toString().equals(alineStyle)) { mTableElement.setProperty(StyleTablePropertiesElement.Align, TableAlignAttribute.Value.LEFT.toString()); } } else { throw new UnsupportedOperationException(); } }
double roundingFactor = 10000.0; double inValue = Math.round(roundingFactor * width / Unit.INCH.unitInMillimiter()) / roundingFactor; String sWidthIN = String.valueOf(inValue) + Unit.INCH.abbr(); mTableElement.setProperty(OdfTableProperties.Width, sWidthIN);
/** * Set the width of the column (in Millimeter). * @param width * the width that will be set to the column (in Millimeter). */ public void setWidth(long width) { String sWidthMM = String.valueOf(width) + Unit.MILLIMETER.abbr(); String sWidthIN = PositiveLength.mapToUnit(sWidthMM, Unit.INCH); splitRepeatedColumns(); maColumnElement.setProperty(OdfTableColumnProperties.ColumnWidth, sWidthIN); //check if need set relative width int index = getColumnIndex(); if (index >= 1) { index = index - 1; } else { index = index + 1; } OdfTableColumn column = null; if (index < getTable().getColumnCount()) { column = getTable().getColumnByIndex(index); } if (column != null) { long prevColumnRelWidth = column.getRelativeWidth(); if (prevColumnRelWidth != 0) { long prevColumnWidth = column.getWidth(); setRelativeWidth(prevColumnRelWidth / prevColumnWidth * width); } } }