Ignore:
Timestamp:
2012-01-24T00:40:20+01:00 (12 years ago)
Author:
bastiK
Message:

fixed #7309 - JOSM should load images included in StartupPageSource from JAR

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/GettingStarted.java

    r4709 r4863  
    1010import java.awt.event.KeyEvent;
    1111import java.io.UnsupportedEncodingException;
     12import java.net.URL;
     13import java.util.regex.Matcher;
     14import java.util.regex.Pattern;
    1215
    1316import javax.swing.JComponent;
     
    122125                EventQueue.invokeLater(new Runnable() {
    123126                    public void run() {
    124                         lg.setText(content);
     127                        lg.setText(fixImageLinks(content));
    125128                        // lg.moveCaretPosition(0);
    126129                    }
     
    133136        new FileDrop(scroller);
    134137    }
     138
     139    private String fixImageLinks(String s) {
     140        Matcher m = Pattern.compile("src=\"http://josm.openstreetmap.de/browser/trunk(/images/.*?\\.png)\\?format=raw\"").matcher(s);
     141        StringBuffer sb = new StringBuffer();
     142        while (m.find()) {
     143            String im = m.group(1);
     144            URL u = getClass().getResource(im);
     145            if (u == null) {
     146                u = getClass().getResource("/images/data/node.png");
     147            }
     148            m.appendReplacement(sb, "src=\"" + u.toString() + "\"");
     149        }
     150        m.appendTail(sb);
     151        return sb.toString();
     152    }
    135153}
Note: See TracChangeset for help on using the changeset viewer.