X-Git-Url: http://git.sourceforge.jp/view?p=neighbornote%2FNeighborNote.git;a=blobdiff_plain;f=src%2Fcx%2Ffbn%2Fnevernote%2Fxml%2FNoteFormatter.java;h=d8baebb8537736a9f32f4d1cbab4f477c33e146d;hp=9347616187b2ba92506661a575a5feca7efe74e4;hb=8bf99212fa081e668888a630803da98081302cfd;hpb=7c04d7784898cfec0165b3d1d02575854f878650 diff --git a/src/cx/fbn/nevernote/xml/NoteFormatter.java b/src/cx/fbn/nevernote/xml/NoteFormatter.java index 9347616..d8baebb 100644 --- a/src/cx/fbn/nevernote/xml/NoteFormatter.java +++ b/src/cx/fbn/nevernote/xml/NoteFormatter.java @@ -13,6 +13,10 @@ import com.trolltech.qt.core.QIODevice; import com.trolltech.qt.core.QIODevice.OpenModeFlag; import com.trolltech.qt.core.QTemporaryFile; import com.trolltech.qt.core.QUrl; +import com.trolltech.qt.core.Qt.BGMode; +import com.trolltech.qt.gui.QColor; +import com.trolltech.qt.gui.QPainter; +import com.trolltech.qt.gui.QPixmap; import com.trolltech.qt.xml.QDomAttr; import com.trolltech.qt.xml.QDomDocument; import com.trolltech.qt.xml.QDomElement; @@ -115,6 +119,69 @@ public class NoteFormatter { return html.toString(); } + private void addImageHilight(String resGuid, QFile f) { + if (enSearch == null || enSearch.hilightWords == null || enSearch.hilightWords.size() == 0) + return; + + // Get the recognition XML that tells where to hilight on the image + Resource recoResource = conn.getNoteTable().noteResourceTable.getNoteResourceRecognition(resGuid); + QByteArray recoData = new QByteArray(recoResource.getRecognition().getBody()); + String xml = recoData.toString(); + + // Get a painter for the image. This is the background (the initial image). + QPixmap pix = new QPixmap(f.fileName()); + QPixmap hilightedPix = new QPixmap(pix.size()); + QPainter p = new QPainter(hilightedPix); + p.drawPixmap(0,0, pix); + + // Create a transparent pixmap. The only non-transparent + // piece is the hilight that will be overlayed to hilight text no the background + QPixmap overlayPix = new QPixmap(pix.size()); + QPainter p2 = new QPainter(overlayPix); + p2.setBackgroundMode(BGMode.TransparentMode); + p2.setBrush(QColor.yellow); + + // Get the recognition data from the note + QDomDocument doc = new QDomDocument(); + doc.setContent(xml); + + // Go through all "item" nodes + QDomNodeList anchors = doc.elementsByTagName("item"); + for (int i=0; i= Global.getRecognitionWeight()) { // Are we above the maximum? + + // Check to see if this word matches something we were searching for. + for (int k=0; k