Example usage for javax.swing.text Document getProperty

List of usage examples for javax.swing.text Document getProperty

Introduction

In this page you can find the example usage for javax.swing.text Document getProperty.

Prototype

public Object getProperty(Object key);

Source Link

Document

Gets the properties associated with the document.

Usage

From source file:org.pmedv.core.components.RelativeImageView.java

/**
 * Checks to see if the absolute path is availabe thru an application global
 * static variable or thru a system variable. If so, appends the relative
 * path to the absolute path and returns the String.
 *///from  w  w w. j av a 2 s .  c o  m
private String processSrcPath(String src) {

    String val = src;
    File imageFile = new File(src);

    if (imageFile.isAbsolute())
        return src;

    boolean found = false;
    Document doc = getDocument();
    if (doc != null) {
        String pv = (String) (doc.getProperty("de.xeinfach.kafenio.docsource"));
        log.debug("de.xeinfach.kafenio.docsource: " + pv);
        if (pv != null) {
            File f = new File(pv, src);
            val = (new File(f.getParent(), imageFile.getPath().toString())).toString();
            found = true;
        }
    }
    /** @todo investigate this - double !found check. */
    if (!found) {

        String fileHtmlPath = new File(".").getAbsolutePath();
        val = (new File(fileHtmlPath, imageFile.getPath())).toString();
        found = true;
    }
    if (!found) {
        String imagePath = System.getProperty("system.image.path.key");
        if (imagePath != null) {
            val = (new File(imagePath, imageFile.getPath())).toString();
        }
    }
    return val;

}