org.wings.style.CSSStyleSheet Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2000,2005 wingS development team.
*
* This file is part of wingS (http://wingsframework.org).
*
* wingS is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* Please see COPYING for the complete licence.
*/
package org.wings.style;
import org.wings.SFont;
import org.wings.io.Device;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.*;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
import java.util.List;
public class CSSStyleSheet implements StyleSheet {
/**
* Apache jakarta commons logger
*/
private final static Logger log = LoggerFactory.getLogger(CSSStyleSheet.class);
private static final Map lengthMapping = new HashMap<>();
static {
lengthMapping.put("pt", 1f);
lengthMapping.put("px", 1.3f);
lengthMapping.put("mm", 2.83464f);
lengthMapping.put("cm", 28.3464f);
lengthMapping.put("pc", 12f);
lengthMapping.put("in", 72f);
}
private final Map map;
/**
* Constructs an empty style sheet.
*/
public CSSStyleSheet() {
map = new HashMap<>();
}
/**
* Constructs a new style sheet instance by parsing the passed input stream into {@link #read(java.io.InputStream)}.
* @param in Input stream containing a valid CSS style sheet file.
*/
public CSSStyleSheet(InputStream in) throws IOException {
this();
read(in);
}
@Override
public void putStyle(Style style) {
map.put(style.getSelector(), style);
//style.setSheet(this);
}
@Override
public Set