Package org.odftoolkit.odfdom.type

Examples of org.odftoolkit.odfdom.type.Color


   *
   * @return the background color
   */
  public Color getBackgroundColor() {
    String property = mElement.getFoBackgroundColorAttribute();
    Color color = null;
    try {
      color = Color.valueOf(property);
    } catch (Exception e) {
      Logger.getLogger(TableCellProperties.class.getName()).log(Level.WARNING, e.getMessage());
    }
View Full Code Here


  @Test
  public void testGetSetCellBackgroundColor() throws Exception {
    int rowindex = 2, columnindex = 0;
    Table table = odsdoc.getTableByName("Sheet1");
    Cell fcell = table.getCellByPosition(columnindex, rowindex);
    fcell.setCellBackgroundColor(new Color("#ffffff"));
    saveods();
    // reload
    loadOutputSpreadsheet();
    table = odsdoc.getTableByName("Sheet1");
    fcell = table.getCellByPosition(columnindex, rowindex);
    // set color as DEFAULT_BACKGROUND_COLOR #FFFFFF
    Assert.assertEquals("#ffffff", fcell.getCellBackgroundColor().toString());

    Color expectedColor = Color.valueOf("#000000");
    fcell.setCellBackgroundColor(expectedColor);
    saveods();
    // reload
    loadOutputSpreadsheet();
    table = odsdoc.getTableByName("Sheet1");
    fcell = table.getCellByPosition(columnindex, rowindex);
    Assert.assertEquals(expectedColor.toString(), fcell.getCellBackgroundColor().toString());

    SpreadsheetDocument ods;
    try {
      ods = SpreadsheetDocument.newSpreadsheetDocument();
      Table tbl = ods.getTableByName("Sheet1");
      Cell cell = tbl.getCellByPosition(0, 0);
      Color actualBackColor = cell.getCellBackgroundColor();
      Assert.assertEquals("#ffffff", actualBackColor.toString());
    } catch (Exception e) {
      Logger.getLogger(TableCellTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

      Cell cell = table.getCellByPosition(2, 2);

      CellStyleHandler cellHandler = cell.getStyleHandler();
      cellHandler.setBackgroundColor(Color.RED);
      //validate
      Color red = cellHandler.getBackgroundColor();
      Assert.assertEquals(Color.RED.toString(), red.toString());
     
      //save
      doc.save(ResourceUtilities.newTestOutputFile("testSupportedLinearMeasure.ods"));
    } catch (Exception e) {
      LOGGER.log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

  }
 
 
  @Test
  public void testSetBorder() {
    Border borderbase = new Border(new Color("#00ccff"), 0.0701, 0.0008, 0.0346, SupportedLinearMeasure.IN);
    try {
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(filename));
      Table table = doc.getTableByName("A");
     
View Full Code Here

   
  }
 
  @Test
  public void testIsTextWrapped() {
    Border borderbase = new Border(new Color("#00ccff"), 0.0701, 0.0008, 0.0346, SupportedLinearMeasure.CM);
    try {
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(filename));
      Table table = doc.getTableByName("A");
      Cell cell = table.getCellByPosition("A14");
View Full Code Here

   * If no background color is set, default background color "#FFFFFF" will be returned.
   *
   * @return the background color of this cell
   */
  public Color getCellBackgroundColor() {
    Color color = Color.WHITE;
    OdfStyleBase styleElement = getCellStyleElement();
    if (styleElement != null) {
      OdfStyleProperty bkColorProperty = OdfStyleProperty.get(OdfStylePropertiesSet.TableCellProperties,
          OdfName.newName(OdfDocumentNamespace.FO, "background-color"));
      String property = styleElement.getProperty(bkColorProperty);
      if (property != null) {
        try {
          color = new Color(property);
        } catch (Exception e) {
          // use default background color White
          color = Color.WHITE;
          Logger.getLogger(OdfTableCell.class.getName()).log(Level.WARNING, e.getMessage());
        }
View Full Code Here

    table = odsdoc.getTableByName("Sheet1");
    fcell = table.getCellByPosition(columnindex, rowindex);
    // set color as DEFAULT_BACKGROUND_COLOR #FFFFFF
    Assert.assertEquals("#ffffff", fcell.getCellBackgroundColorString());

    Color expectedColor = Color.valueOf("#000000");
    fcell.setCellBackgroundColor(expectedColor);
    saveods();
    // reload
    loadOutputSpreadsheet();
    table = odsdoc.getTableByName("Sheet1");
    fcell = table.getCellByPosition(columnindex, rowindex);
    Assert.assertEquals(expectedColor.toString(), fcell.getCellBackgroundColor().toString());

    OdfSpreadsheetDocument ods;
    try {
      ods = OdfSpreadsheetDocument.newSpreadsheetDocument();
      OdfTable tbl = ods.getTableByName("Sheet1");
      OdfTableCell cell = tbl.getCellByPosition(0, 0);
      Color actualBackColor = cell.getCellBackgroundColor();
      Assert.assertEquals("#ffffff", actualBackColor.toString());
    } catch (Exception e) {
      Logger.getLogger(TableCellTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

  @Test
  public void testGetSetCellBackgroundColor() throws Exception {
    int rowindex = 2, columnindex = 0;
    Table table = odsdoc.getTableByName("Sheet1");
    Cell fcell = table.getCellByPosition(columnindex, rowindex);
    fcell.setCellBackgroundColor(new Color("#ffffff"));
    saveods();
    // reload
    loadOutputSpreadsheet();
    table = odsdoc.getTableByName("Sheet1");
    fcell = table.getCellByPosition(columnindex, rowindex);
    // set color as DEFAULT_BACKGROUND_COLOR #FFFFFF
    Assert.assertEquals("#ffffff", fcell.getCellBackgroundColor().toString());

    Color expectedColor = Color.valueOf("#000000");
    fcell.setCellBackgroundColor(expectedColor);
    saveods();
    // reload
    loadOutputSpreadsheet();
    table = odsdoc.getTableByName("Sheet1");
    fcell = table.getCellByPosition(columnindex, rowindex);
    Assert.assertEquals(expectedColor.toString(), fcell.getCellBackgroundColor().toString());

    SpreadsheetDocument ods;
    try {
      ods = SpreadsheetDocument.newSpreadsheetDocument();
      Table tbl = ods.getTableByName("Sheet1");
      Cell cell = tbl.getCellByPosition(0, 0);
      Color actualBackColor = cell.getCellBackgroundColor();
      Assert.assertEquals("#ffffff", actualBackColor.toString());
    } catch (Exception e) {
      Logger.getLogger(TableCellTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
      Assert.fail(e.getMessage());
    }
  }
View Full Code Here

      Cell cell = table.getCellByPosition(2, 2);

      CellStyleHandler cellHandler = cell.getStyleHandler();
      cellHandler.setBackgroundColor(Color.RED);
      //validate
      Color red = cellHandler.getBackgroundColor();
      Assert.assertEquals(Color.RED.toString(), red.toString());
     
      //save
      doc.save(ResourceUtilities.newTestOutputFile("testSupportedLinearMeasure.ods"));
    } catch (Exception e) {
      LOGGER.log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

  }
 
 
  @Test
  public void testSetBorder() {
    Border borderbase = new Border(new Color("#00ccff"), 0.0701, 0.0008, 0.0346, SupportedLinearMeasure.IN);
    try {
      SpreadsheetDocument doc = SpreadsheetDocument.loadDocument(ResourceUtilities
          .getTestResourceAsStream(filename));
      Table table = doc.getTableByName("A");
     
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.type.Color

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.