本文整理汇总了Java中org.fit.cssbox.swingbox.util.Constants类的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Constants类属于org.fit.cssbox.swingbox.util包,在下文中一共展示了Constants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadElementAttributes
import org.fit.cssbox.swingbox.util.Constants; //导入依赖的package包/类
private void loadElementAttributes()
{
org.w3c.dom.Element elem = findAnchorElement(box.getElement());
Map<String, String> elementAttributes = anchor.getProperties();
if (elem != null)
{
anchor.setActive(true);
elementAttributes.put(Constants.ELEMENT_A_ATTRIBUTE_HREF, elem.getAttribute("href"));
elementAttributes.put(Constants.ELEMENT_A_ATTRIBUTE_NAME, elem.getAttribute("name"));
elementAttributes.put(Constants.ELEMENT_A_ATTRIBUTE_TITLE, elem.getAttribute("title"));
String target = elem.getAttribute("target");
if ("".equals(target))
{
target = "_self";
}
elementAttributes.put(Constants.ELEMENT_A_ATTRIBUTE_TARGET, target);
// System.err.println("## Anchor at : " + this + " attr: "+
// elementAttributes);
}
else
{
anchor.setActive(false);
elementAttributes.clear();
}
}
示例2: getBox
import org.fit.cssbox.swingbox.util.Constants; //导入依赖的package包/类
/**
* Gets the box reference from properties.
*
* @param v
* just a view.
* @return the box set in properties, if there is one.
*/
public static final Box getBox(View v)
{
if (v instanceof CSSBoxView) return getBox((CSSBoxView) v);
AttributeSet attr = v.getAttributes();
if (attr == null)
{
throw new NullPointerException("AttributeSet of " + v.getClass().getName() + "@"
+ Integer.toHexString(v.hashCode()) + " is set to NULL.");
}
Object obj = attr.getAttribute(Constants.ATTRIBUTE_BOX_REFERENCE);
if (obj != null && obj instanceof Box)
{
return (Box) obj;
}
else
{
throw new IllegalArgumentException("Box reference in attributes is not an instance of a Box.");
}
}
示例3: getToolTipText
import org.fit.cssbox.swingbox.util.Constants; //导入依赖的package包/类
@Override
public String getToolTipText(float x, float y, Shape allocation)
{
String val = "";
String tmp;
Map<String, String> elementAttributes = anchor.getProperties();
if (title != null && !"".equals(title))
val = val + "<b>" + title + "</b><br>";
tmp = elementAttributes.get(Constants.ELEMENT_A_ATTRIBUTE_TITLE);
if (tmp != null && !"".equals(tmp))
val = val + "<i>" + tmp + "</i><br>";
if (val.equals("")) {
if (alt != null && ! "".equals(alt)) {
val = val + "<b>" + alt + "</b><br>";
}
}
tmp = elementAttributes.get(Constants.ELEMENT_A_ATTRIBUTE_HREF);
if (tmp != null && !"".equals(tmp) && "".equals(val)) val = val + tmp;
return "".equals(val) ? null : "<html>" + val + "</html>";
}
示例4: getToolTipText
import org.fit.cssbox.swingbox.util.Constants; //导入依赖的package包/类
@Override
public String getToolTipText(float x, float y, Shape allocation)
{
Map<String, String> elementAttributes = anchor.getProperties();
String val = "";
String tmp;
// image title
if (title != null && !"".equals(title))
val = val + "<b>" + title + "</b><br>";
// anchor title
tmp = elementAttributes.get(Constants.ELEMENT_A_ATTRIBUTE_TITLE);
if (tmp != null && !"".equals(tmp))
val = val + "<i>" + tmp + "</i><br>";
if (val.equals("")) {
if (alt != null && ! "".equals(alt)) {
val = val + "<b>" + alt + "</b><br>";
}
}
// anchor href
tmp = elementAttributes.get(Constants.ELEMENT_A_ATTRIBUTE_HREF);
if (tmp != null && !"".equals(tmp) && "".equals(val)) val = val + tmp;
return "".equals(val) ? null : "<html>" + val + "</html>";
}
示例5: TextBoxView
import org.fit.cssbox.swingbox.util.Constants; //导入依赖的package包/类
/**
* Instantiates a new text based view, able to display rich text. This view
* corresponds to TextBox in CSSBox. <br>
* <a href="http://www.w3.org/TR/CSS21/box.html">Box Model</a>
*
* @param elem
* the elem
*
*/
public TextBoxView(Element elem)
{
super(elem);
AttributeSet tmpAttr = elem.getAttributes();
Object obj = tmpAttr.getAttribute(Constants.ATTRIBUTE_BOX_REFERENCE);
anchor = (Anchor) tmpAttr.getAttribute(Constants.ATTRIBUTE_ANCHOR_REFERENCE);
if (obj instanceof TextBox)
{
box = (TextBox) obj;
}
else
{
throw new IllegalArgumentException("Box reference is not an instance of TextBox");
}
tmpRect = new Rectangle();
}
示例6: getToolTipText
import org.fit.cssbox.swingbox.util.Constants; //导入依赖的package包/类
@Override
public String getToolTipText(float x, float y, Shape allocation)
{
if (anchor.isActive())
{
Map<String, String> elementAttributes = anchor.getProperties();
String val = "";
String tmp;
tmp = elementAttributes.get(Constants.ELEMENT_A_ATTRIBUTE_TITLE);
if (tmp != null && !"".equals(tmp))
val = val + "<i>" + tmp + "</i><br>";
tmp = elementAttributes.get(Constants.ELEMENT_A_ATTRIBUTE_HREF);
if (tmp != null && !"".equals(tmp) && "".equals(val)) val = val + tmp;
return "".equals(val) ? null : "<html>" + val + "</html>";
}
//return "NotLink: " + this;
return null;
}
示例7: setPropertiesFromAttributes
import org.fit.cssbox.swingbox.util.Constants; //导入依赖的package包/类
/**
* Sets the properties from the attributes.
*
* @param attr
* the new properties from attributes
*/
protected void setPropertiesFromAttributes(AttributeSet attr)
{
if (attr != null)
{
Font newFont = (Font) attr.getAttribute(Constants.ATTRIBUTE_FONT);
if (newFont != null)
{
setFont(newFont);
}
else
{
// the font is the most important for us
throw new IllegalStateException("Font can not be null !");
}
setForeground((Color) attr.getAttribute(Constants.ATTRIBUTE_FOREGROUND));
setFontVariant((String) attr.getAttribute(Constants.ATTRIBUTE_FONT_VARIANT));
@SuppressWarnings("unchecked")
List<TextDecoration> attribute = (List<TextDecoration>) attr.getAttribute(Constants.ATTRIBUTE_TEXT_DECORATION);
setTextDecoration(attribute);
}
}
示例8: loadElementAttributes
import org.fit.cssbox.swingbox.util.Constants; //导入依赖的package包/类
private void loadElementAttributes()
{
org.w3c.dom.Element elem = Anchor.findAnchorElement(box.getElement());
Map<String, String> elementAttributes = anchor.getProperties();
if (elem != null)
{
anchor.setActive(true);
elementAttributes.put(Constants.ELEMENT_A_ATTRIBUTE_HREF, elem.getAttribute("href"));
elementAttributes.put(Constants.ELEMENT_A_ATTRIBUTE_NAME, elem.getAttribute("name"));
elementAttributes.put(Constants.ELEMENT_A_ATTRIBUTE_TITLE, elem.getAttribute("title"));
String target = elem.getAttribute("target");
if ("".equals(target))
{
target = "_self";
}
elementAttributes.put(Constants.ELEMENT_A_ATTRIBUTE_TARGET, target);
// System.err.println("## Anchor at : " + this + " attr: "+
// elementAttributes);
}
else
{
anchor.setActive(false);
elementAttributes.clear();
}
}
示例9: getToolTipText
import org.fit.cssbox.swingbox.util.Constants; //导入依赖的package包/类
@Override
public String getToolTipText(float x, float y, Shape allocation)
{
String val = "";
String tmp;
Map<String, String> elementAttributes = anchor.getProperties();
if (title != null && !"".equals(title))
val = val + "<b>" + title + "</b><br>";
tmp = elementAttributes.get(Constants.ELEMENT_A_ATTRIBUTE_TITLE);
if (tmp != null && !"".equals(tmp))
val = val + "<i>" + tmp + "</i><br>";
tmp = elementAttributes.get(Constants.ELEMENT_A_ATTRIBUTE_HREF);
if (tmp != null && !"".equals(tmp)) val = val + tmp;
return "".equals(val) ? null : "<html>" + val + "</html>";
}
示例10: getToolTipText
import org.fit.cssbox.swingbox.util.Constants; //导入依赖的package包/类
@Override
public String getToolTipText(float x, float y, Shape allocation)
{
Map<String, String> elementAttributes = anchor.getProperties();
String val = "";
String tmp;
// image title
if (title != null && !"".equals(title))
val = val + "<b>" + title + "</b><br>";
// anchor title
tmp = elementAttributes.get(Constants.ELEMENT_A_ATTRIBUTE_TITLE);
if (tmp != null && !"".equals(tmp))
val = val + "<i>" + tmp + "</i><br>";
// anchor href
tmp = elementAttributes.get(Constants.ELEMENT_A_ATTRIBUTE_HREF);
if (tmp != null && !"".equals(tmp)) val = val + tmp;
return "".equals(val) ? null : "<html>" + val + "</html>";
}
示例11: getToolTipText
import org.fit.cssbox.swingbox.util.Constants; //导入依赖的package包/类
@Override
public String getToolTipText(float x, float y, Shape allocation)
{
if (anchor.isActive())
{
Map<String, String> elementAttributes = anchor.getProperties();
String val = "";
String tmp;
tmp = elementAttributes.get(Constants.ELEMENT_A_ATTRIBUTE_TITLE);
if (tmp != null && !"".equals(tmp))
val = val + "<i>" + tmp + "</i><br>";
tmp = elementAttributes.get(Constants.ELEMENT_A_ATTRIBUTE_HREF);
if (tmp != null && !"".equals(tmp)) val = val + tmp;
return "".equals(val) ? null : "<html>" + val + "</html>";
}
//return "NotLink: " + this;
return null;
}
示例12: ElementBoxView
import org.fit.cssbox.swingbox.util.Constants; //导入依赖的package包/类
/**
* @param elem
*/
public ElementBoxView(Element elem)
{
// Y axis as default
super(elem);
majorAxis = Y_AXIS;
AttributeSet tmpAttr = elem.getAttributes();
Object obj = tmpAttr.getAttribute(Constants.ATTRIBUTE_BOX_REFERENCE);
if (obj != null && obj instanceof ElementBox)
{
box = (ElementBox) obj;
if (box instanceof BlockBox)
{
if (((BlockBox) box).isFloating())
{
majorAxis = X_AXIS;
}
}
}
else
{
throw new IllegalArgumentException("Box reference is null or not an instance of ElementBox");
}
obj = tmpAttr.getAttribute(Constants.ATTRIBUTE_ANCHOR_REFERENCE);
if (obj != null && obj instanceof Anchor)
{
anchor = (Anchor) obj;
}
else
{
throw new IllegalArgumentException("Anchor reference is null or not an instance of Anchor");
}
oldDimension = new Dimension();
tmpRect = new Rectangle();
loadElementAttributes();
}
示例13: createAttributes
import org.fit.cssbox.swingbox.util.Constants; //导入依赖的package包/类
protected SimpleAttributeSet createAttributes()
{
// get all 'working variables' and make an AttributeSet.
// hint: use MutableAttributeSet & recycle instance
SimpleAttributeSet res = new SimpleAttributeSet();
res.addAttribute(Constants.ATTRIBUTE_ANCHOR_REFERENCE, anchor);
res.addAttribute(Constants.ATTRIBUTE_BOX_REFERENCE, box);
// TODO: v niektorych pripadoch jr box==null, ako je to mozne ?
// ak nacitam novu stranku a v testapp mam stary strom elementov a view
// objektov
// a zbehol GC tak hadze null , NPE!
return res;
}
示例14: createAttributes
import org.fit.cssbox.swingbox.util.Constants; //导入依赖的package包/类
protected SimpleAttributeSet createAttributes()
{
// called from getAttributes()
SimpleAttributeSet res = super.createAttributes();
res.addAttribute(Constants.ATTRIBUTE_REPLACED_CONTENT, content);
return res;
}
示例15: createAttributes
import org.fit.cssbox.swingbox.util.Constants; //导入依赖的package包/类
private AttributeSet createAttributes()
{
// get all 'working variables' and make an AttributeSet.
SimpleAttributeSet res = new SimpleAttributeSet();
res.addAttribute(Constants.ATTRIBUTE_BOX_REFERENCE, box);
res.addAttribute(Constants.ATTRIBUTE_ANCHOR_REFERENCE, anchor);
res.addAttribute(Constants.ATTRIBUTE_FONT_VARIANT, fontVariant);
res.addAttribute(Constants.ATTRIBUTE_TEXT_DECORATION, textDecoration);
res.addAttribute(Constants.ATTRIBUTE_FONT, font);
res.addAttribute(Constants.ATTRIBUTE_FOREGROUND, foreground);
return res;
}