• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

pagination in jtextpane

 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, here is a SSCCEE for pagination of jtextpane. it uses a stylededitorkit

my problem is if i change the content type to text/rtf or text/html it does not work. any idea what is wrong? both rtfeditorkit adn htmleditorkit inherit from stylededitorkit so the result should be the same but it is not

if anyone can give ideas or workaround, it would be greatly appreciated. thank you

 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

both rtfeditorkit adn htmleditorkit inherit from stylededitorkit



Yes they extend StyledEditKit, they don't extend CetiEditorKit, so they know nothing about your custom code.

 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i mean

CetiEditorKit extends StyledEditorKit in the code

if i do

CetiEditorKit extends RTFEditorKit or HTMLEditorKit, it does not work in this mode
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mey be this would help
http://java-sl.com/Pagination_In_JEditorPane.html
?

If you don't need WYSIWYG but only preview pages and print you can use this
http://java-sl.com/JEditorPanePrinter.html

Actually the main problem of your code is that you try to replace views with your page views based on some elements name. HTMLEditorKit has different views structure and the views with the names your use just don't exist.
 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi stan, i saw your code before i created this top but it caters to only a stylededitorkit. if i use it as an htmleditorkit, it does not work
 
Stanislav Lapitsky
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I explained you are trying to replace incorrect views.

See http://java-sl.com/JEditorPaneStructureTool.html
As you can see on the screenshow (Views structure part) HTMLEditorKit uses different views for different elements. See BranchElement(body) and view for the element is BodyBlockView.

So try to debug your view factory and see which elements with names comes in the create() method and which views are created for the elements. The replace proper elements with your views. You views should extend proper HTML views classes.
 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi stan! thanks for the tip. i managed to integrate your sectionview, pageableparagraphview and multipageview to my working app

i just need to adjust the width and height of the wysiwyg area.
 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi stan. got a few questions

1) im trying to do a real time switch between pageable and normal view, does this require having to call setEditorKit again in pageable mode in order for the jtextcomponent to display them as paginated?

2) the pagination in the htmleditorkit works fine, unless if the text im writing is bulleted, it does not move the next bullet list to the next page. is this a view issue?
 
Stanislav Lapitsky
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) I think all you need is to pass a flag to the root view you have. E.g. via document.properties or directly to rootView. textPane.getUI().getRootView() and down to the necessary view. The view should check the flag and do your paginated layout or the original layout.

2)For the list view and guess for the table view you need to write something similar to ParagraphView. An algorithm to move children based on the pagination info you have from parent.

Actually the ListView and tableView extend the same BoxView so noting difficult to write the same code.
 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i used the document.getProperty() approach inside the views and added super.method calls in your classes if it is not in multipage mode.

however, i noticed that when i resize my editor's jframe, the paint somehow gets messed up, until i resize it again. im thinking of doing a dirty hack that, if resized, will resize it programmatically again by 1 pixel perhaps.

anyone got ideas what methods get called when a resize occurs? validate()? revalidate()? etc?
 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i did a simpler and quicker hack instead. placing a flag in the editorkit class's viewfactory and calling textpane.setText() method to reload the current content. since my module doesnt deal with huge documents, this was a quicker workaround for me rather than doing modifying your classes.

as for html bullets, i figure id make use of your same pageableparagraphview class to paginate paragraphs since my bullets contain <li><p></p></li> inserthtml actions whenever i insert a bullet but when it gets to the next page, it seems to bring the whole <ul> block to the next page instead of the last <li></li> of the <ul> set.

my editorkit class looks something like this


any suggestions?
 
Stanislav Lapitsky
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My suggestion is the same. Write the same functionality as for paragraphs for ListView.
Hierarchy is
BlockView (e.g. body)
ListView
ListItemView
ParagraphView

If you replace paragraph or list item views ListView remains the same block which can't be split.
 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just to clarify. i'd have to create a view for listview, another for listitemview and maybe use the same pageableparagraphview class for a paragraphview? thanks
 
Stanislav Lapitsky
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have no simple answer. My solution supposes one level children pagination. It means if you list item contains several paragraphs and sum of heights of the paragraphs is bigger than page height the list item isn't split. In other words the pagination doesn't split nested elements.
So all you need is to create custom view for lists. The view should check list items heights and shift list items to the next page. If you need more complicated logic my simple example should be extended to adress the same pagination to nested elements.
 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the quick reply and clarification.

think ill put this on hold as views are pretty complicated, so much more this bullet pageable view. your existing samples were helpful though for me accomplishing what i needed to do.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am also facing the same problem. when is replace the StyledEditorKit with HTMLEditorKit, the view does not render the pageable. please post your cutomized Views for Pageable HtmlEditorKit
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how did you do your scalling please let me know
 
No. No. No. No. Changed my mind. Wanna come down. To see this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic