Trying to make the e-book reader in JavaFX

This entry JavaFX Advent Calendar 2012 is day 15.

Yesterday @ skrb 's  irof san drawing song by JavaFX was.

This is a translated version of JavaFXで電子書籍リーダーを作ってみた.

 

This year is e-book first year. You e-book do you enjoy life?

A recent study session JavaFX 8th at @aoetk to see a demo of the Pagination control do I use this control to feel good?

f: id: tarchan: 20121215191920p: plain

 To be displayed in the specified page spread when you click the index of the left. (screenshot of manga is "ブラックジャックによろしく"). I will send the next page by pressing the up and down cursor key. Like to continue to slide and I feel good.

 

Source code was published on GitHub.

tarchan / TwoFace · GitHub

Pagination control JavaFX does not appear in the library in Scene Builder 1.1-b13, had to be added by editing the FXML.

Is the only supported format PDF. To read the PDF is PDFRenderer-0.9.1.jar was used. Image PDFRenderer returned java.awt.Image class so, at this rate JavaFX it can not be displayed in the control. So SwingFXUtils.toFXImage method javafx.scene.image.Image are converted into class. To find this method from a PNG image to a temporary file and writes  javafx.scene.image.Image hassle because it was loaded into the class that I was saved ;-)

        PDFPage pdfPage = pdfFile.getPage(idx);
        Rectangle2D rect = pdfPage.getBBox();
        int width = (int) rect.getWidth();
        int height = (int) rect.getHeight();
        java.awt.Image awtImage = pdfPage.getImage(width, height, rect, null, true, true);
        image = SwingFXUtils.toFXImage((BufferedImage) awtImage, image);

At home iMac and Magic Trackpad environment does not correspond so that the, I was expecting that the Pagination control can flick x-(

I want you to support it by all means Pagination control buttons of the window full screen so valid.

Japanese manga has so many right binding, we want a option to specify the direction of the scroll Pagination control it. Stylesheet Why does direction specified properties?

JavaFXで電子書籍リーダーを作ってみた

このエントリは JavaFX Advent Calendar 2012 の15日目です。

昨日は @skrb さんの いろふさん絵描き歌 by JavaFX でした。

 

今年は電子書籍元年と言われてはや幾年。みなさん電子書籍生活を楽しんでますか?

僕も i文庫HD や Kindle を使って楽しんでいますが、たくさんの本を読んでいると、もっと自分の読書スタイルに合った電子書籍リーダーを作りたいという思いが募っていました。

先日の 第8回 JavaFX 勉強会@aoetk さんの Pagination コントロールのデモを見て、このコントロールいい感じに使えるんじゃね?とピンときました。 

f:id:tarchan:20121215191920p:plain

 左のインデックスをクリックすると指定されたページを見開きで表示します(スクリーンショットのマンガは「ブラックジャックによろしく」です)。そのままカーソルキー上下を押すと次々とページ送りします。ビュンビュンとスライドしていく様が気持ちいいです。

 

ソースコードは GitHub に公開しました。

tarchan/TwoFace · GitHub

Pagination コントロールは JavaFX Scene Builder 1.1-b13 ではライブラリに表示されないので、FXMLを編集して追加する必要がありました。

対応フォーマットは PDF のみです。PDF の読み込みには PDFRenderer-0.9.1.jar を使用しました。PDFRenderer が返すイメージは java.awt.Image クラスなので、このままでは JavaFX のコントロールで表示できません。そこで SwingFXUtils.toFXImage メソッドで javafx.scene.image.Image クラスに変換しています。このメソッドを見つけるまでは一時ファイルに PNG イメージを書き出してから javafx.scene.image.Image クラスに読み込むという手間をかけていたので助かりました(^^;

        PDFPage pdfPage = pdfFile.getPage(idx);
        Rectangle2D rect = pdfPage.getBBox();
        int width = (int) rect.getWidth();
        int height = (int) rect.getHeight();
        java.awt.Image awtImage = pdfPage.getImage(width, height, rect, null, true, true);
        image = SwingFXUtils.toFXImage((BufferedImage) awtImage, image);

自宅では iMac + Magic Trackpad という環境なので、Pagination コントロールがフリック操作できることを期待していたのですが対応していないみたいです><

ウインドウのフルスクリーンボタンは有効なので Pagination コントロールもぜひ対応して欲しいです。

それと日本のマンガは右綴じが多いので、Pagination コントロールのスクロール方向を指定するオプションが欲しいですね。スタイルシートの direction プロパティは指定できないんでしょうか?